From 5488603b071252b13a6619094e24bebe7b4bb327 Mon Sep 17 00:00:00 2001 From: marpies Date: Tue, 20 May 2014 23:29:16 +0200 Subject: [PATCH] Fix memory leaks on Android. Stop channel regardless of its position inside onSoundComplete method. Channel position for some reason does not match the sound length on Android. --- lib/src/treefortress/sound/SoundInstance.as | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/src/treefortress/sound/SoundInstance.as b/lib/src/treefortress/sound/SoundInstance.as index 30368f3..71186c8 100644 --- a/lib/src/treefortress/sound/SoundInstance.as +++ b/lib/src/treefortress/sound/SoundInstance.as @@ -325,12 +325,11 @@ package treefortress.sound soundCompleted.dispatch(this); } } - //Clear out any old channels... - for(var i:int = oldChannels.length; i--;){ - if(channel.position == sound.length){ - stopChannel(channel); - oldChannels.splice(i, 1); - } + + stopChannel( channel ); + var index:int = oldChannels.indexOf( channel ); + if( index >= 0 ) { + oldChannels.splice( index, 1 ); } }