Actionscript 3 动态播放音频时出现ActionScript 3错误

Actionscript 3 动态播放音频时出现ActionScript 3错误,actionscript-3,flash,actionscript,air,Actionscript 3,Flash,Actionscript,Air,我正在为Air iOS编写一个游戏。我有一个音频文件,保存在与.fla文件相同的目录中。下面是我用来播放它的代码: import flash.net.URLRequest; var snd:Sound = new Sound(new URLRequest("507560_-BlastProcess-.mp3")); snd.play(0, 40); 这是我在W Air调试启动器中测试时遇到的错误: [SWF] Spike%20Jungle.swf - 72668 bytes after

我正在为Air iOS编写一个游戏。我有一个音频文件,保存在与.fla文件相同的目录中。下面是我用来播放它的代码:

import flash.net.URLRequest;

var snd:Sound = new Sound(new  URLRequest("507560_-BlastProcess-.mp3")); 
snd.play(0, 40);
这是我在W Air调试启动器中测试时遇到的错误:

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

如何修复此问题?

需要跨域,或者文件路径不正确

您的AIR应用程序可能与mp3不在同一文件夹中运行。查看已编译的air应用程序的存储位置,并将mp3移动到该文件夹


您可能还想使用SoundChannel,这样您就可以停止您的
MainTimeLine
类的第128行中的声音了?StreamError-这可能是一个未找到的文件、一个安全限制或您正试图播放一个未完全加载的文件-不能确定,可能可以立即开始播放,但我会先等待加载程序触发Event.COMPLETE,然后再播放。@AndreiNikolaenko我试过:
import flash.events.Event;导入flash.media.Sound;导入flash.net.URLRequest;var s:Sound=新声音();s、 addEventListener(Event.COMPLETE,onSoundLoaded);var-req:URLRequest=newurlrequest(“HexagonForce.mp3”);s、 负载(req);函数onSoundLoaded(event:event):void{var localSound:Sound=event.target as Sound;localSound.play();}
但是我仍然得到相同的错误。然后我就没有主意了。可能声音文件本身已损坏,无法读取?