# AS3 Tween not finishing

**URL:** <https://forum.kirupa.com/t/as3-tween-not-finishing/315097>\
**Category:** flash\
**Created:** [October 17, 2010, 10:08pm UTC](https://forum.kirupa.com/t/as3-tween-not-finishing/315097 "2010-10-17T22:08:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kt1978](https://avatars.discourse-cdn.com/v4/letter/k/e274bd/32.png) [@kt1978](https://forum.kirupa.com/u/kt1978)\
**Post date:** [October 17, 2010, 10:08pm UTC](https://forum.kirupa.com/t/as3-tween-not-finishing/315097/1 "2010-10-17T22:08:55Z")

</div>

All

I have a problem that I have read a few other threads about, but the solutions that are offered don’t seem to work for me.

The solution offered was to declare the tween variables outside the function…

I have done this, but every now and then it doesn’t finish the tween.

Here is my code for that part…Any Ideas!!!

```auto
var alphaTween:Tween;
var myTimer:Timer=new Timer(150,0);

myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER, addMC);
    
function addMC(event:TimerEvent):void {

    var mc:MovieClip = new mClip();
    loadArea.addChildAt(mc,1);
    mc.mouseChildren=false;
    mc.mouseEnabled=false;

    mc.gotoAndStop(Math.ceil(Math.random()*6));
    mc.x=Math.random()*loadArea.width*0.9;
    mc.y=Math.random()*loadArea.height*0.9;
    mc.width=mc.width*Math.random()*1.5;
    mc.scaleY=mc.scaleX;
    mc.rotation=Math.random()+1*360;

    alphaTween = new Tween(mc,"alpha",None.easeNone,1,0,1,true);
    alphaTween.addEventListener(TweenEvent.MOTION_FINISH, fadeOut);
    function fadeOut(event:TweenEvent):void {
        if(loadArea.contains(mc)){
           loadArea.removeChild(mc);
           }
    }

}

```
