2

我只需要一些关于如何通过 Javascript 点击播放音频剪辑的指导。

4

1 回答 1

0

为了从 flash 到 javascript 来回交谈,您应该使用 flash.external.ExternalInterface 类和回调。

闪存 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();
}

网页

<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>

请原谅我的任何错误,代码未经测试,但应该给你正确的想法。

于 2011-05-27T15:05:06.590 回答