4 Replies Latest reply on Aug 5, 2010 8:53 AM by iamhepp

    New Tween onMotionFinished not working

    DazFaz Level 1

      Hello everyone,

       

      I have :

       

      //-----Class File

       

      import mx.transitions.*;

      import mx.transitions.easing.*;

       

      class cTransition {

      public function cTransition(){

      }

      public function AnimateScreen() {
           myINTween = new Tween(arguments[0], "_alpha", None.easeNone, 0, 100, .25, true);
           myINTween.onMotionFinished = function() {

                     AnimateScreen()

           }

      }

      }

       

      //------

       

      //-----fla timeline

      var myMov:Object

      myMov = new cTransition ()

      myMov.AnimateScreen(myMov._childMov)

       

      This code is within a class and the problem is that the "myMovieToAnimate" movieClip animates the first time around but when the tween finishes, it does not call the AnimateScreen() function again, why is this.

       

      Any help here would be very much appreciated.

       

      Thanks

        • 1. Re: New Tween onMotionFinished not working
          kglad Adobe Community Professional & MVP

          it's not passing the target of the tween.  fix that.


          • 2. Re: New Tween onMotionFinished not working
            DazFaz Level 1

            Its not passing the target of the tween???

             

            Surley "myMov.AnimateScreen(myMov._childMov)" is doing this and this is being picked up with "arguments[0]"

            • 3. Re: New Tween onMotionFinished not working
              kglad Adobe Community Professional & MVP

              use:


              myINTween.onMotionFinished = function() {

                              AnimateScreen(this.obj)

                   }

              • 4. Re: New Tween onMotionFinished not working
                iamhepp

                I have a similar problem in that my function is not being called when onMotionFinished is called. Any ideas on what I am doing wrong??

                 

                ****************************** MY CLASS ******************************
                import fl.transitions.*;
                import mx.transitions.Tween;

                 

                class skitter.view.MainMenuView extends UIObject {

                private var sliderTween

                 

                 

                public function MainMenuView(target:MovieClip, depth:Number){

                ...constructor code...

                }

                /** Animate Main Menu **/
                    private function slideMenuItems(dir:Number):Void{
                       var newLoc:Number;
                        //To Make Sure Direction Calls Don't Call This Again Until Animation is Complete
                        failSafe = true;
                       
                        // Move the Indicated Direction
                        switch( dir ){
                            case 1:
                                // Set New Slide Amount
                                newLoc = sliderStage._x + (mItemsArray[mItemsArray.length-1].getWidth() + offset);
                                // Move the Stage
                                sliderTween = new Tween(sliderStage, "_x", mx.transitions.easing.None.easeInOut, sliderStage._x, newLoc, speed, true);
                                break;
                            case 2:
                                // Set New Slide Amount
                                newLoc = sliderStage._x - (mItemsArray[0].getWidth() + offset);
                                // Move the Stage
                                sliderTween = new Tween(sliderStage, "_x", mx.transitions.easing.None.easeInOut, sliderStage._x, newLoc, speed, true);
                               break;
                            default :
                                  break;
                        }
                        failSafe = false;
                       
                        sliderTween.onMotionFinished = function() {
                            trace("CALL REDRAW FUNCTION")
                            Delegate.create(this, redrawMenu( dir ));
                            //redrawMenu( dir );
                        }
                    } // END slideMenuItems()
                   
                    /** Redraw Items on sliderStage**/
                    private function redrawMenu( dir:Number ):Void{
                        trace("\t** REDRAW CALLED");

                        ...code to draw items...
                    }

                } // END CLASS