问题
Good Day, I working in Android/IOS App using AIR 3.5. In this project I download ZIP file and extracted in specific folder, after that I using the assets ( IMG, XML and Sounds), everything work fine but when I load the sounds it's keep show this error. > Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error. I tried to give it static location in android drive but same error happened. I tried to use URLRequest, FileStream, URLStream and same thing happened. I traced all files bath in the folder and it's give me all the baths correct. This is the code.
trace('AliSoundFile/' + ob.sound);
var soundFile:File = File.documentsDirectory.resolvePath('AliSoundFile/'+ob.sound);
var files:Array = soundFile.getDirectoryListing();
trace((File.documentsDirectory.resolvePath('AliSoundFile/'+ob.sound).nativePath) );
//sound = new Sound( new URLRequest ('AliSoundFile/1.mp3'));
sound.addEventListener(IOErrorEvent.IO_ERROR, sound_ioError);
for ( var i:uint = 0 ; i < files.length ; i++)
{
if (files[i].isDirectory )
{
var arr:Array = files[i].getDirectoryListing();
for ( var j:uint = 0 ; j < arr.length ; j++)
trace('J:-> ',arr[j].nativePath);
}
trace('I:-> ',files[i].nativePath);
}
soundStreen = new FileStream();
soundStreen.openAsync(soundFile, FileMode.READ);
soundStreen.addEventListener( Event.COMPLETE, soundStreen_complete);
soundStreen.addEventListener( IOErrorEvent.IO_ERROR, soundStreen_ioError);
trace('end');
private function soundStreen_complete(e:Event):void
{
var ba:ByteArray = new ByteArray();
soundStreen.readBytes( ba );
_loadSound = new Loader();
_loadSound.contentLoaderInfo.addEventListener( Event.COMPLETE, soundLoadbytesComplete );
_loadSound.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadSound_progress);
_loadSound.loadBytes( ba );
}
private function soundLoadbytesComplete(e:Event):void
{
sound.play();
sound = e.currentTarget.content as Sound;
soundStreen.close();
}
Anyone can help me with this. Thank you
回答1:
First: To handle this unhandled exceptions add addEventListener for IOErrorEvent.IO_ERROR to contentLoaderInfo Second: Loader class is used to load SWF files or image (JPG, PNG, or GIF) files ( see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.html ) so the problem is in that you pass invalid stream (Sound streem ). To play a file check this: http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d25.html
回答2:
We had similar 2032 issues, and was discovered due to Apache 2.4 upgrade. We have since rolled back the Apache and all is well!
回答3:
I was also getting this error even though I was handling the IOErrorEvent... or so I thought but it turned out that a HTTPStatusEvent (500 in my case) was being triggered before the IOError event and I was removing the event listeners in my HTTPStatusEvent handler before the IOError event. Derp!
来源:https://stackoverflow.com/questions/15106960/error-2044-unhandled-ioerrorevent-text-error-2032-stream-error