as3中类的多个实例
我有一个在as3的主文档类中加载声音的函数,这个函数接受输入链接并开始加载这个路径,例如相同的函数:
private function loadSound(url:String):void{
var req:String = 'sound/'+url+'.mp3'
sound_path = new URLRequest(req)
main_sound = new Sound()
main_sound.load(sound_path)
main_sound.play()
}
当这个函数调用时,多个声音对象开始播放,我如何解决这个问题只播放声音这个时间上课?
i have a function to load sound in main document class in as3,this function accept input link and begin to load this path for example same function :
private function loadSound(url:String):void{
var req:String = 'sound/'+url+'.mp3'
sound_path = new URLRequest(req)
main_sound = new Sound()
main_sound.load(sound_path)
main_sound.play()
}
when this function call, sound object multiple start playing,how i solve this problem for play only sound class in this time ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其放在 loadSound() 函数的开头:
如果关键帧中有此代码,请确保调用 stop() 以防止它一遍又一遍地执行代码。
如果你把它放在类文件(.as)中,听起来它被调用了两次
Place this at beginning of your loadSound() function:
If you have this code in a keyframe make sure you are calling stop() to prevent it from executing the code over and over.
If you have it in a class file (.as) it sounds like it is getting called twice