用JavaScript播放Flash音频

| 我只需要有关如何在单击Javascript时播放音频剪辑的一些指导。     
已邀请:
        为了在Flash和javascript之间来回通信,您应该使用flash.external.ExternalInterface类和回调。 Flash as3
import flash.external.ExternalInterface;
import flash.net.URLRequest;

//Create the javascript \"playSound\" on the swf object
ExternalInterface.addCallback(\"playSound\", playSound);

//Create our sound object
var sound:Sound = new Sound;
//Load my.mp3 into our sound object
sound:Sound .load(new URLRequest(\"my.mp3\"));

function playSound(){
    sound.play();
}
HTML页面
<script language=\"javascript\">
    var swf;

    //Wait for page load to complete
    window.onload = init;

    //initialize our swf variable where mySWF is the id of the swf object on the page
    function init(){
        swf = document.getElementById(\"mySWF\");
    }

    //call our external function on the swf
    function playSound(){
        swf.playSound();
    }
</script>
原谅我任何错误,代码未经测试,但应该给您正确的主意。     

要回复问题请先登录注册