【发布时间】:2015-02-06 16:55:01
【问题描述】:
我正在为 Air iOS 编写游戏。我有一个音频文件,与我的 .fla 文件保存在同一目录中。这是我用来播放它的代码:
import flash.net.URLRequest;
var snd:Sound = new Sound(new URLRequest("507560_-BlastProcess-.mp3"));
snd.play(0, 40);
这是我在 Air Debug Launcher 中测试时遇到的错误:
[SWF] Spike%20Jungle.swf - 72668 bytes after decompression
Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.
at SpikeJungle_fla::MainTimeline/frame1()[SpikeJungle_fla.MainTimeline::frame1:128]
at runtime::ContentPlayer/loadInitialContent()
at runtime::ContentPlayer/playRawContent()
at runtime::ContentPlayer/playContent()
at runtime::AppRunner/run()
at ADLAppEntry/run()
at global/runtime::ADLEntry()
[UnloadSWF] Spike%20Jungle.swf
Test Movie terminated.
我该如何解决这个问题?
【问题讨论】:
-
MainTimeLine类的第 128 行是什么? -
StreamError - 要么是找不到文件,要么是安全限制,或者您正在尝试播放未完全加载的文件 - 不能确定,也许可以立即开始播放,但我会先等待加载程序触发 Event.COMPLETE 然后才开始播放。
-
@AndreiNikolaenko 我试过这个:
import flash.events.Event; import flash.media.Sound; import flash.net.URLRequest; var s:Sound = new Sound(); s.addEventListener(Event.COMPLETE, onSoundLoaded); var req:URLRequest = new URLRequest("HexagonForce.mp3"); s.load(req); function onSoundLoaded(event:Event):void { var localSound:Sound = event.target as Sound; localSound.play(); }但我仍然得到同样的错误。 -
那我就没主意了。也许声音文件本身已损坏,无法读取?
标签: actionscript-3 flash actionscript air