Skip to content

Commit

Permalink
Get the error handler in place before starting to load sounds.
Browse files Browse the repository at this point in the history
Otherwise, nothing's listening for the IOErrorEvent yet and things blow up
spectacularly if the file isn't there.

I'm a little freaked out that it's still going straight into calling onInit()
in case of a streaming sound, but hopefully anything using that is behaving
properly in the face of a streaming error.
  • Loading branch information
deadmoose committed Jan 4, 2012
1 parent bd0caee commit 813af42
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ public class SoundResource extends Resource
_pan = getLoadParam(PAN, 0); _pan = getLoadParam(PAN, 0);


if (hasLoadParam(URL)) { if (hasLoadParam(URL)) {
_sound = new Sound(new URLRequest(getLoadParam(URL))); _sound = new Sound();

// Immediately set up the error listener to protect against blowing up
_sound.addEventListener(IOErrorEvent.IO_ERROR, onIOError);

// And THEN start it loading
_sound.load(new URLRequest(getLoadParam(URL)));


var stream :Boolean = var stream :Boolean =
getLoadParam(STREAM, false) || getLoadParam(STREAM, false) ||
Expand All @@ -117,7 +123,6 @@ public class SoundResource extends Resource
onInit(); onInit();
} else { } else {
_sound.addEventListener(Event.COMPLETE, onInit); _sound.addEventListener(Event.COMPLETE, onInit);
_sound.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
} }


} else if (hasLoadParam(EMBEDDED_CLASS)) { } else if (hasLoadParam(EMBEDDED_CLASS)) {
Expand Down

0 comments on commit 813af42

Please sign in to comment.