2 Replies Latest reply on Sep 6, 2011 7:19 AM by kglad

    Making an instance move?

    aidenkael17

      I need to move an instance of the class Snowboarder from x -1.00 to x 199.99.  How do I link from my actionscript of class Enter?  Here is what I have

      class Enter
      {
           function onEnterFrame()
           {
                if Key.isDown(Key.ENTER));  //if key Enter is pressed start the animation
                //code for animation
           }
      }
      

       

      Is another class even needed?  This "Enter" class will only be used to move a snowboarder over the screen and have a logo apear behind him.

        • 1. Re: Making an instance move?
          kglad Adobe Community Professional & MVP

          in your fla or another class:

           

          var m:Move=new Move(yourmovieclip,startx,starty,endx,endy,duration);

           

          //////////

           

          class Move{

          public function Move(mc:MovieClip,x1:Number,y1:Number,x2:Number,y2:Number,t:Number) {
          new mx.transitions.Tween(mc, "_x", mx.transitions.easing.None.easeNone, x1, x2, t, true);
          new mx.transitions.Tween(mc, "_y", mx.transitions.easing.None.easeNone, y1, y2, t, true);
          }

          1 person found this helpful
          • 2. Re: Making an instance move?
            kglad Adobe Community Professional & MVP

            even better would be:

             

            class TweenC

             

            public function TweenC() {
            //
            }
            public function to(mc:MovieClip,propertyS:String,startProp,endProp,t:Number){
            new mx.transitions.Tween(mc, propertyS, mx.transitions.easing.None.easeNone, startProp, endProp, t, true);
            }
            }

             

            and use:

             

            var tweenC:TweenC=new TweenC();  // done once

             

             

            tweenC.to(snowboarder,"_x",-1,200,2);

            1 person found this helpful