# AS3 - Memory leak problem

**URL:** <https://forum.kirupa.com/t/as3-memory-leak-problem/321996>\
**Category:** flash\
**Created:** [May 6, 2011, 5:31pm UTC](https://forum.kirupa.com/t/as3-memory-leak-problem/321996 "2011-05-06T17:31:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cordylear](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@cordylear](https://forum.kirupa.com/u/cordylear)\
**Post date:** [May 6, 2011, 5:31pm UTC](https://forum.kirupa.com/t/as3-memory-leak-problem/321996/1 "2011-05-06T17:31:57Z")

</div>

Hi everyone,

I’m new to flash. I’ve created a flash file that is a marketing loop.

I created frame labels in the timeline and added movie clips to the timeline. I animate each movie clip using AS3. Once the animation for a movie clip is complete, I go to the next frame label and animate the objects in that label.

However, the file is freezing and it’s a memory leak problem. How can I remove objects that I’ve created in the time line so they no longer exist when the file moves to the next frame label?

Below is an example of my code for a frame label:

stop();  
import fl.transitions.Tween;  
import fl.transitions.TweenEvent;  
import fl.transitions.easing.\*;  
import flash.utils.Timer;  
import flash.events.TimerEvent;  
//position of text  
text5\_mc.alpha=0;  
tools\_mc.x=650;  
//bring in text  
var text5AlphaTween:Tween=new Tween(text5\_mc,“alpha”,Regular.easeIn,0,1,1,true);

//listen for text to complete motion, move in tools image  
text5AlphaTween.addEventListener(TweenEvent.MOTION\_FINISH,donetext5);  
function donetext5(e:TweenEvent):void {  
var toolsInTween:Tween=new Tween(tools\_mc,“x”,Regular.easeIn,650,0,1,true);  
text5AlphaTween.removeEventListener(TweenEvent.MOTION\_FINISH,donetext5);

//listen for image motion to complete, move out text  
toolsInTween.addEventListener(TweenEvent.MOTION\_FINISH,text5Out);

function text5Out(e:TweenEvent):void{  
var text5OutTween:Tween=new Tween(text5\_mc,“alpha”,Regular.easeIn,1,0,1,true);  
toolsInTween.removeEventListener(TweenEvent.MOTION\_FINISH,text5Out);  
//listen for text motion to complete, move out image  
text5OutTween.addEventListener(TweenEvent.MOTION\_FINISH,toolsOut);  
function toolsOut(e:TweenEvent):void {  
var toolsOutTween:Tween=new Tween(tools\_mc,“x”,Regular.easeIn,0,-642,1,true);  
text5OutTween.removeEventListener(TweenEvent.MOTION\_FINISH,toolsOut);

//listen for image motion to complete, go to next frame label  
toolsOutTween.addEventListener(TweenEvent.MOTION\_FINISH,atPage7);

function atPage7(e:TweenEvent):void {  
toolsOutTween.removeEventListener(TweenEvent.MOTION\_FINISH,atPage7);  
MovieClip(root).gotoAndStop(“page7”);

}  
}  
}  
}

Any advice on how I can stop the memory leak?

Thanks
