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

ActionScript 3 Error when dynamically playing audio

我正在为 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.

我该如何解决这个问题?

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

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

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

您可能还想使用 SoundChannel 来停止声音