# Help with component and tween class

**URL:** https://forum.kirupa.com/t/help-with-component-and-tween-class/219421
**Category:** flash
**Created:** [March 16, 2007, 12:25pm UTC](https://forum.kirupa.com/t/help-with-component-and-tween-class/219421 "2007-03-16T12:25:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Tay511](https://avatars.discourse-cdn.com/v4/letter/t/c89c15/32.png) [@Tay511](https://forum.kirupa.com/u/Tay511)
#### Post date: [March 16, 2007, 12:25pm UTC](https://forum.kirupa.com/t/help-with-component-and-tween-class/219421/1 "2007-03-16T12:25:47Z")

</div>

Hi All,

I have main movieClip which creates several instances of a library component each with a different id\_number variable. The components are made listeners of the main movieClip so when it broadcasts moveComp(id\_number,newX) only the matching component respond and moves to the new x location.

Everything works fine but the problem I have is trying get the tween class onMotionFinished to call a function either in the parent movieClip or a function in the component itself. What am I doing wrong? Can anyone help??

Many Thanks,  
Ty

This is the relevant bit of the components script.

```auto
//---------8<-----
myCom.prototype.moveComp = function(compId, newX) {
    if (compId == this.id_number) {
        trace("moving component "+this.id_number);
        var myTweenX = new Tween(this, "_x", Regular.easeOut, this._x, newX, 0.2, true);
        myTweenX.onMotionFinished = function() {
            // trace works but the id_number is undefned
            trace(“move finished - ”+this.id_number);
            // calling a ‘parent_mc’ function or a function in the component doesn’t work!!
            this._parent.moveFinished(this.id_number);
            this.moveFinished();
        };
    }
};
//
myComp.prototype.moveFinished = function() {
    trace(“move finished - ”+this.id_number);
};
//---------8<-----

```
