Reputation: 19
I have the following code:
import flash.media.Sound;
import flash.net.URLRequest;
function playBase():void
{
var urlRequest:URLRequest = new URLRequest("mybase.mp3");
var sound:Sound = new Sound();
sound.load(urlRequest);
sound.play();
}
playBase()
I have mybase.mp3 into my LIBRARY section, but the DEBUG OUTPUT show me:
Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.
Why?
Upvotes: 1
Views: 643
Reputation: 11590
URLRequest is used to load an external file, so either
1: save the mp3 file as "mybase.mp3" to the same directory that is running your Flash/AIR App, instead of in your library.
OR
2: In your library right click on the mp3 file > properties > and export for actionscript using a name like MyBaseSound
. Once you do that you should be able to reference the sound like a class, something like:
var s:MyBaseSound = new MyBaseSound();
s.play()
EDIT
If going with option 1 you likely will want to go to Publish Settings then to your Android Settings area and under included files add that file. This should add it to your app bundle / package. (In CS6 it is the little wrench icon, but in CS5 I don't recall the exact steps to get there for Android, but I know the iOS settings page has a similar included files option.)
Upvotes: 2