我有一个带有声音的Flash动画,具有播放,暂停,停止,开始和结束按钮的声音。
当我发布它时,我必须包括mp3文件以及swf文件。
我该怎么做才能单独播放swf文件以便播放整个内容?
我正在使用Flash CS 3和ActionScript 3.0
这是我的代码:var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
var lastPosition:Number = 0;
var soundIsPlaying:Boolean = true;
mySound.load(new URLRequest("saloma.mp3"));
myChannel = mySound.play();
所有这些按钮将进入功能,go.addEventListener(MouseEvent.CLICK,govid);
function govid(event:MouseEvent):void{
play();
if(!soundIsPlaying){
myChannel = mySound.play(lastPosition);
soundIsPlaying = true;
}
}
我也在使用场景进行导航,gte.addEventListener(MouseEvent.CLICK,gotoend);
function gotoend(event:MouseEvent):void{
gotoAndStop(1,"ending");
}
谢谢 :)
最佳答案
我会写答案的,但是已经回答了……
首先,在您的媒体库中,通过右键单击,选择属性并在“链接”部分中编辑“类”字段来设置声音文件的类链接。在这个例子中它将是Class:FogHorn
import flash.utils.getDefinitionByName;
var SoundClass:Class = getDefinitionByName("FogHorn") as Class;
var newSound:Sound = new SoundClass();
newSound.play()
来源:@ Allan中的Actionscript 3: playing sound from library with name from string
关于actionscript-3 - 嵌入声音,以便在发布时我们不必将其包括在与swf文件相同的文件夹中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17959972/