Search code examples
actionscript-3flashactionscriptair

ActionScript 3 Error when dynamically playing audio


I am writing a game for Air iOS. I have an audio file, saved in the same directory as my .fla file. Here is the code I am using to play it:

import flash.net.URLRequest;

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

This is the error I get when testing in thew 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.

How do I fix this?


Solution

  • Either need a cross-domain or the path to the file is incorrect.

    Your AIR app is probably not running in the same folder as your mp3. See where your compiled air app is being stored and move the mp3 to that folder.

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

    You may also want to use a SoundChannel so you can stop the sound