Axel
Axel copied to clipboard
Sounds overflow issue
If you play sounds or musics by Ax.sound()/Ax.music(), it will new a AxSound and push it into the Ax.sounds (an AxGroup) for updates.
But if the AxSound.destroy() has been called after play (there have another bug that it will never been called by listener), the object reference still within the Ax.sounds group, and updating.
Should be a way to remove it from the group after playback.
And if the program like your tutorial, let's say just using Ax.sound(FIRE); after thousands plays it will crashed, by array overflow and updating a null reference.
UPDATE:
I fixed this issue by:
- add a reference "parent:AxGroup" into the AxSound object, the contractor will need a reference passed;
- at "destory()" add "parent.remove(this)" to ensure it removed from the update group;
- MAJOR BUG, at AxSound.as, function "play()", line "sound.addEventListener(Event.SOUND_COMPLETE, destroy);", it should be "soundChannel.addEventListener". Otherwise it will never callback destory() function. And the callback function should have at least one parameter. So I do this way: ... soundChannel.addEventListener(Event.SOUND_COMPLETE, onSoundChannelComplete); ... public function onSoundChannelComplete(sender:Event):void { destroy(); }
That would fixed this issue.