# onMotionChanged = function()

**URL:** <https://forum.kirupa.com/t/onmotionchanged-function/200166>\
**Category:** Uncategorized\
**Created:** [September 9, 2006, 11:45am UTC](https://forum.kirupa.com/t/onmotionchanged-function/200166 "2006-09-09T11:45:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![henriklars1](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@henriklars1](https://forum.kirupa.com/u/henriklars1)\
**Post date:** [September 9, 2006, 11:45am UTC](https://forum.kirupa.com/t/onmotionchanged-function/200166/1 "2006-09-09T11:45:38Z")

</div>

Sorry, for beeing noob with this. But if someone needs some java help im you man. :nerd:  
However, here is the problem:

I have the code below inside a class extending mx.core.UIComponent, all of this works fine  
except for calling drawLine() from the tween\_handler. I feel like Ive tried everything…  
Anyone know a solution to this matter?

```auto
    
class Seperator extends mx.core.UIComponent {

.....

public function move(xpos:Number,ypos:Number,length:Number) {
        var counter:Number = 1;
        new Tween(top, "_y", Elastic.easeOut, top._y, ypos, 2, true);
        new Tween(top, "_x", Elastic.easeOut, top._x, xpos, 2, true);
        new Tween(bottom, "_y", Elastic.easeOut, bottom._y, ypos+length, 2, true);
        var tween_handler:Object = new Tween(bottom, "_x", Elastic.easeOut, bottom._x, xpos, 2, true);
        tween_handler.onMotionChanged = function() {
            trace("iteration" + counter); // *<--- this works fine.*
            counter++;
            **[COLOR=DarkRed]drawLine();[/COLOR]**// *<-- Doesnt seem to be calling this function at all, if I trace(drawLine()); it says "undefined".* }
    }
    
    
    public function drawLine() {
        trace("top._x");
        line.clear();
        line.lineStyle(1, 0x2D2D2D);
        
        line.moveTo(top._x, top._y);
        line.lineTo(bottom._x, bottom._y);
    
        updateAfterEvent();
    }

```
