3 Replies Latest reply on Jan 12, 2011 5:05 AM by Ned Murphy

    Tween class not resetting _y value

    aditi_bk

      Hi,

       

      I am trying to move a movieclip down using Actionscript. Then when a user fires a back event [which is successfully firing] the movieclip is then required to go up again. The code is:

       

      trace("fholder _y org: " + folioholdermc._y); // THIS COMES OUT TO BE -601


      var yDown1:Tween = new Tween(folioholdermc, "_y", Bounce.easeOut, -601, -449, 3, true);

      trace("step 1 called");

      trace("fholder _y down1: " + folioholdermc._y);  //THIS ALSO COMES OUT AS -601 ????? Though I can see the clip in the right position

       

      yDown1.onMotionFinished = function()

      {

      trace("ydown1 done");        //This trace is fired and then it stops

      var yDown2:Tween = new Tween(folioholdermc, "_y", Bounce.easeOut, -449, -297, 3, true);

      };


      yDown2.onMotionFinished = function()

      {

      trace("fholder _y down2: " + folioholdermc._y);

      trace("ydown2 done");

      var yDown3:Tween = new Tween(folioholdermc, "_y", Bounce.easeOut, -297, -148, 3, true);

      };


      yDown3.onMotionFinished = function()

      {

      trace("ydown3 done");

      var yDown4:Tween = new Tween(folioholdermc, "_y", Bounce.easeOut, -148, 0, 3, true);

      };


      yDown4.onMotionFinished = function()

      {

      trace("ydown4 done");

       

      folioholdermc.addEventListener("back",rollBackUp); //Does not register the event which is successfully fired

       

      function rollBackUp()

      {

      trace("got roll back");


      folioholdermc.bclip.gotoAndStop("up");

      var yUp1:Tween = new Tween(folioholdermc, "_y", Bounce.easeOut, folioholdermc._y, -148, 3, true);

      trace("step 1 up called");


      yUp1.onMotionFinished = function()

      {

      var yUp2:Tween = new Tween(folioholdermc, "_y", Bounce.easeOut, folioholdermc._y, -297, 3, true);

      };


      yUp2.onMotionFinished = function()

      {

      var yUp3:Tween = new Tween(folioholdermc, "_y", Bounce.easeOut, folioholdermc._y, -449, 3, true);

      };


      yUp3.onMotionFinished = function()

      {

      var yUp4:Tween = new Tween(folioholdermc, "_y", Bounce.easeOut, folioholdermc._y, -601, 3, true);

      };


      yUp4.onMotionFinished = function()

      {

      folioholdermc.bclip.soapmachine.gotoAndPlay(40);

      };


      }

       

      };

       

      What am I doing wrong here??? Any help will be greatly appreciated...

        • 1. Re: Tween class not resetting _y value
          Ned Murphy Adobe Community Professional & MVP

          I can't say that I follow what you are trying to do, and thus what it is failing to do, but I see that you are declaring variables within functions, but then are also trying to assign things to them outside of the function.  When you declare a variable inside a function, it only has scope within that function...  So in the first instance if you change the coding to the following you can probably get that second tween's finished function to execute...

           

           

          yDown1.onMotionFinished = function()

          {

               trace("ydown1 done"); 

               var yDown2:Tween = new Tween(folioholdermc, "_y", Bounce.easeOut, -449, -297, 3, true);

               yDown2.onMotionFinished = yD2Finished;

          };


          function yD2Finished()

          {

               trace("fholder _y down2: " + folioholdermc._y);

               trace("ydown2 done");

               var yDown3:Tween = new Tween(folioholdermc, "_y", Bounce.easeOut, -297, -148, 3, true);

               // etc...

          };

          • 2. Re: Tween class not resetting _y value
            aditi_bk Level 1

            Thank you Ned,

             

            You are a life saver...I can't believe I missed that..a basic scope issue of all things......thanks again..

            • 3. Re: Tween class not resetting _y value
              Ned Murphy Adobe Community Professional & MVP

              You're welcome