Skip to content

Commit

Permalink
Fixed a couple bugs in SoundManager
Browse files Browse the repository at this point in the history
  • Loading branch information
skyboy committed Nov 27, 2010
1 parent 56f88bb commit 0d332ef
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions skyboy/media/SoundManager.as
Expand Up @@ -184,9 +184,9 @@
sndTransform ||= Transforms[type];
var b:int = channels.indexOf(null);
var a:DataStore = channels[b] = new DataStore(Sounds[type], b, loops, sndTransform);
a.play(startTime);
callback ||= VOID;
a.addEventListener(Event.SOUND_COMPLETE, function(e:Event):void { e.target.removeEventListener(e.type, arguments.callee); soundEnded(e, type, null); callback.call(null, e); } );
a.addEventListener(Event.SOUND_COMPLETE, function(e:Event):void { e.target.removeEventListener(Event.SOUND_COMPLETE, arguments.callee); soundEnded(e, type, a); callback.call(null, e); } );
a.play(startTime);
return true;
}
} else {
Expand Down Expand Up @@ -370,11 +370,11 @@
/**
* protected functions
**/
protected function valid(id:int):Boolean {
return id > -1 && id < maximumSounds && Sounds[id];
protected function valid(id:uint):Boolean {
return id < maximumSounds && Sounds[id];
}
protected function validC(id:int):Boolean {
return id > -1 && id < maxPlayableSounds && channels[id];
protected function validC(id:uint):Boolean {
return id < maxPlayableSounds && channels[id];
}
protected function increment(id:int):void {
++currentPlayingSounds;
Expand Down Expand Up @@ -431,7 +431,7 @@ internal class DataStore {
b.removeEventListener(e.type, arguments.callee);
var remove:Boolean = loop();
if (remove) {
if (listener.length == 2) try { listener(e, a); return; } catch (er:*) { }
if (listener.length == 2) try { listener(e, this); return; } catch (er:*) { }
var a:Array = listner;
a[2] = listener;
b.addEventListener.apply(b, a);
Expand Down Expand Up @@ -472,7 +472,6 @@ internal class DataStore {
}
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void {
var a:DataStore = this;
this.listener = listener;
listner = [type, listenerRepeater, useCapture, priority, useWeakReference];
}
Expand Down

0 comments on commit 0d332ef

Please sign in to comment.