2015-02-06 68 views
0

我正在为Air iOS编写游戏。我有一个音频文件,保存在与.fla文件相同的目录中。下面是我使用的发挥它的代码:ActionScript 3动态播放音频时出错

import flash.net.URLRequest; 

var snd:Sound = new Sound(new URLRequest("507560_-BlastProcess-.mp3")); 
snd.play(0, 40); 

这是错误的thew空气调试发射测试时,我得到:

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

我该如何解决这个问题?

+0

什么是你的'MainTimeLine'类128线? – CyanAngel 2015-02-06 17:14:21

+0

StreamError - 这是要找的文件,安全限制或者您正在播放未完全加载的文件 - 无法肯定地说,也许可以立即开始播放,但我会先等待装载器发起一个Event.COMPLETE,然后才能播放。 – 2015-02-06 17:33:52

+0

@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”); (req); function onSoundLoaded(event:Event):void { var localSound:Sound = event.target as Sound; localSound.play(); }' 但我仍然得到相同的错误。 – EdwardCorrell 2015-02-09 14:44:37

回答

0

要么需要跨网域,要么文件路径不正确。

您的AIR应用程序可能未与您的mp3在同一文件夹中运行。查看您的编译好的空中应用程序的存储位置,并将mp3移至该文件夹。

http://www.judahfrangipane.com/blog/2007/02/15/error-2032-stream-error/

您可能还需要使用的SoundChannel这样你就可以停止声音