# \[AS2\] referring to external object within function?

**URL:** <https://forum.kirupa.com/t/as2-referring-to-external-object-within-function/193241>\
**Category:** flash\
**Created:** [July 10, 2006, 12:37am UTC](https://forum.kirupa.com/t/as2-referring-to-external-object-within-function/193241 "2006-07-10T00:37:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![angusf](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@angusf](https://forum.kirupa.com/u/angusf)\
**Post date:** [July 10, 2006, 12:37am UTC](https://forum.kirupa.com/t/as2-referring-to-external-object-within-function/193241/1 "2006-07-10T00:37:31Z")

</div>

I have a class with a method “movePaneTo”. I want to create a tween and do multiple things at every step not just change a movieclip property. Tweening a property of the class seems to be working but how do I  
[LIST=1]  
[_]refer to the class that initiated the tween from the onMotionChanged handler, so that the trace would display the current value?  
[_]Should I be using a listener for the onMotionChanged?  
[\*]What’s this kind of function (the one assigned to “onMotionChanged”) callled?[/LIST]

```auto

public function movePaneTo(y) {
   var tweenY:Tween = new Tween(this, "worldY", Regular.easeOut, worldY, (worldY+y), 10);

   tweenY.onMotionChanged = function():Void {
      trace(worldY);
   }
}

```

Thanks for your help.
