6 Replies Latest reply on Mar 19, 2007 4:47 AM by Tay511

    Component and tween class help

    Tay511
      Hi All,

      I have a simple component which is dynamically added to a movieClip (‘parent_mc’) and is then made a listener of that movieClip. I’m creating 5 different component instances and each one is given a unique ‘id_number’. The component uses a tween calss function for moving to a different x position. The ‘parent_mc’ broadcasts a message (this.broadcastMessage("moveComp", compId, newX); and only the component with the matching id moves to the new position.

      Everything works as expected but the problem I’m having is trying to call a function to let the 'parent_mc' know when the tween has finished. Can anyone help??

      Thanks,
      Ty

      This is a cut down of the components script.

        • 1. Re: Component and tween class help
          mclem Level 1
          Ahh i see your error, you are using this inside the onMotionFinished function... however you are inside "myTweenX" and not inside myCom, try this._parent inside the myTweenX.onMotionFinished function...
          • 2. Re: Component and tween class help
            Tay511 Level 1
            I have tried this and several other variations but no success.

            It seems to be a pathName problem but I can't figure out where the tween (object!) is in relation to the 'myComp' instance. I tried calling a global function (test(_parent.id_number)) in the onMotionFinished function as a test but the id_number comes back as undefined.

            The global function is just:

            • 3. Re: Component and tween class help
              tonyhigham Level 1
              Using the Tween class callbacks can be a pain. For some reason, their pathing is handled differently than other objects. The path to your parent_mc from inside the onMotionFinished callback will be:

              this.obj._parent
              • 4. Re: Component and tween class help
                Tay511 Level 1
                You didn't explain the 'obj' bit and how I define it.

                Anyway, I have done a work around by placing a movieClip in the component to handle the tween and call the moveFinished function in the component when it's done.

                There must be a way to call the same moveFinished function from within the moveComp.myTweenX.onMotionFinished function.

                Thanks for the responses.
                Ty

                The movieClip code is this:

                • 5. Re: Component and tween class help
                  tonyhigham Level 1
                  You dont define the obj bit, its a preexisting property of tween objects that references the scope in which they were created. If you want to call the moveFinished function, which looks like it resides at the _parent of the MC that holds the tween:

                  this.obj._parent.moveFinished()

                  should do the trick.
                  • 6. Re: Component and tween class help
                    Tay511 Level 1
                    Thanks for your help Tony - works fine now. I also send the id_number when I call the function so it now looks like this.

                    this.obj._parent.moveFinished(this.obj.id_number)

                    Ty