Axel icon indicating copy to clipboard operation
Axel copied to clipboard

Sounds overflow issue

Open FancySensei opened this issue 12 years ago • 0 comments

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:

  1. add a reference "parent:AxGroup" into the AxSound object, the contractor will need a reference passed;
  2. at "destory()" add "parent.remove(this)" to ensure it removed from the update group;
  3. 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.

FancySensei avatar Jan 11 '13 10:01 FancySensei