# Tween.onMotionFinished.. repeatedly

**URL:** <https://forum.kirupa.com/t/tween-onmotionfinished-repeatedly/192146>\
**Category:** Uncategorized\
**Created:** [June 26, 2006, 4:16pm UTC](https://forum.kirupa.com/t/tween-onmotionfinished-repeatedly/192146 "2006-06-26T16:16:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![takethetrain](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@takethetrain](https://forum.kirupa.com/u/takethetrain)\
**Post date:** [June 26, 2006, 4:16pm UTC](https://forum.kirupa.com/t/tween-onmotionfinished-repeatedly/192146/1 "2006-06-26T16:16:39Z")

</div>

I’m trying to animate entirely in AS for the first time. (Woo!) I’m using the Tween class, with the very convenient Tween.onMotionFinished to invoke my next animation. But once I get pretty far into it, it starts to look like this:

```auto

var centerType:Number = (Stage.width / 4) * 3;
var transTween:Tween = new Tween(grayGrad, "_alpha", Strong.easeOut, grayGrad._alpha, 0, 1, true);
transTween.onMotionFinished = function() {
     var iamPos:Tween = new Tween(iam_txt, "_x", Strong.easeOut, iam_txt._x, iam_txt._x + 100, .7, true);
     iamPos.onMotionFinished = function() {
          var prepPos:Tween = new Tween(prepared_txt, "_x", Strong.easeOut, prepared_txt._x, centerType, .5, true);
          var prepAlpha:Tween = new Tween(prepared_txt, "_alpha", Strong.easeOut, 0, 100, .5, true);
          prepAlpha.onMotionFinished = function() {
               setTimeout(function ():Void {
                    var engaPos:Tween = new Tween(engaged_txt, "_x", Strong.easeOut, engaged_txt._x, centerType, .5, true);
                    var engaAlpha:Tween = new Tween(engaged_txt, "_alpha", Strong.easeOut, 0, 100, .5, true);
                    var prepPos2:Tween = new Tween(prepared_txt, "_x", Strong.easeOut, prepared_txt._x, Stage.width + 100, .5, true);
                    var prepAlpha2:Tween = new Tween(prepared_txt, "_alpha", Strong.easeOut, 100, 0, .5, true);
               }, 100);
          }
     };
     var photoAlpha:Tween = new Tween(photo1, "_alpha", Strong.easeOut, photo1._alpha, 100, .5, true);
};

```

[FONT=Courier New][/FONT]

I’ve found that, when applying a tween to a function, I am unable to refer to that tween (specifically, onMotionFinished) from outside of it. This works okay but leaves me with some rather ugly ActionScript!

Any suggestions?
