Skip to content

Sounds overflow issue #23

@FancySensei

Description

@FancySensei

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions