# Tweening recursion problem? Help me out please

**URL:** <https://forum.kirupa.com/t/tweening-recursion-problem-help-me-out-please/212314>\
**Category:** Uncategorized\
**Created:** [January 10, 2007, 3:40am UTC](https://forum.kirupa.com/t/tweening-recursion-problem-help-me-out-please/212314 "2007-01-10T03:40:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lowey](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@lowey](https://forum.kirupa.com/u/lowey)\
**Post date:** [January 10, 2007, 3:40am UTC](https://forum.kirupa.com/t/tweening-recursion-problem-help-me-out-please/212314/1 "2007-01-10T03:40:46Z")

</div>

Hello,

I have a problem with the movie I have crreated. After several cycles of the movie from start to finish it appears to be grossly out of sync and cpu usage rapidly climbs.

The movie is based over 5 frames. The AS from frame one is detailed below. Basically I am attaching a movie clip symbol, tweening it and then setting a timeout before moving to the next frame.

On the next frame (frame2), I am attaching another clip and removing the previouse one and then executing code much the same as below. This is repeated over the remaing 3 frames before returning to frame one where the loop begins again.

As you can see from the code I have placed a trace on the xScale.onMotionFinished function and a further trace on the delay function to indicate the transition between frames.

However, while frame 2 is executing, the trace for the Frame 1 onMotionFinished occurs again as detailed below in the trace output.

Why is the recurring and how do I stop it from happening???

TRACE OUTPUT

Frame 1 onMotionFinished  
Frame 1 onMotionFinished  
Frame 1 onMotionFinished  
Frame 1 ends  
Frame 1 onMotionFinished  
Frame 2 onMotionFinished  
Frame 1 onMotionFinished  
Frame 2 onMotionFinished  
Frame 1 onMotionFinished  
Frame 2 onMotionFinished  
Frame 1 onMotionFinished  
Frame 2 ends

FRAME ONE SCRIPT

kt = attachMovie(“kText”, “kText1”, 10);

import mx.transitions.Tween;  
import mx.transitions.easing.\*;

var xScale:Tween = new Tween(kt, “\_rotation”, Elastic.easeInOut, 0, 360, 4, true);  
var xPos:Tween = new Tween(kt, “\_x”, Elastic.easeIn, 234, Stage.width/2, 4, true);  
var yPos:Tween = new Tween(kt, “\_y”, Elastic.easeIn, 30,Stage.height,4,true);  
var Height:Tween = new Tween(kt, “\_Height”, Regular.easeOut, 0,Stage.height,4,true);  
var Width:Tween = new Tween(kt, “\_Width”, Regular.easeInOut, 0, Stage.width-100,4,true);

xScale.onMotionFinished = function() {  
this.yoyo();//  
trace(“Frame 1 onMotionFinished”);  
};

function delay(frame:Number) {  
gotoAndPlay (frame);  
trace(“Frame 1 ends”);  
}

stop();  
frame = 2;  
setTimeout(delay,16000,frame)
