5 Replies Latest reply on Jan 13, 2011 6:51 AM by aditi_bk

    Tween executing but not displaying any change

    aditi_bk

      Hi,

       

      I have a dynamic tween within a function, which basically makes a movie clip visible, after it had been made invisible by another tween call.

       

      Code to make clip invisible:

       

      function imgopen(){

       

      var fholderDark:Tween = new Tween(this.mc_load1360.folioholdermc, "_alpha", Regular.easeOut, 100, 0, 1, true);

      fholderDark.onMotionFinished = function(){ trace("folioholdermc vanished");}

      var darkenDark:Tween = new Tween(this.mc_load1360.darken, "_alpha", Regular.easeOut, 0, 100, 1, true);

      darkenDark.onMotionFinished = function(){ trace("dark 100");}

       

      }

       

      Code to make it visible

       

      function imgOut(){

       

           var fholderBack:Tween = new Tween(this.mc_load1360.folioholdermc,"_alpha", Regular.easeOut, 0, 100, 1, true);

           fholderBack.onMotionFinished = function(){ trace("fholder back finished");}

           var darkenBack:Tween = new Tween(this.mc_load1360.darken,"_alpha", Regular.easeOut, 100, 0, 1, true);

           darkenBack.onMotionFinished = function(){ trace("darken back finished");}

      }

       

      imgOut is called when an event is triggered. I can see the trace function messages from within the function, but I don't see folioholdermc after imgopen has been called once. How is that possible?? If the tween is executing then should the movieclip not be visible????

       

        • 1. Re: Tween executing but not displaying any change
          Ned Murphy Adobe Community Professional & MVP

          Chances are the tween is not executing, just the function that contains it.  If you get rid of the "this" in the tweening code it might work.  If you trace(this) you might see why it isn't.

           

          function imgopen(){
          var fholderDark:Tween = new Tween(mc_load1360.folioholdermc, "_alpha", Regular.easeOut, 100, 0, 1, true);
          fholderDark.onMotionFinished = function(){ trace("folioholdermc vanished");}
          var darkenDark:Tween = new Tween(mc_load1360.darken, "_alpha", Regular.easeOut, 0, 100, 1, true);
          darkenDark.onMotionFinished = function(){ trace("dark 100");}
          }

           

          function imgOut(){
               var fholderBack:Tween = new Tween(mc_load1360.folioholdermc,"_alpha", Regular.easeOut, 0, 100, 1, true);
               fholderBack.onMotionFinished = function(){ trace("fholder back finished");}
               var darkenBack:Tween = new Tween(mc_load1360.darken,"_alpha", Regular.easeOut, 100, 0, 1, true);
               darkenBack.onMotionFinished = function(){ trace("darken back finished");}
          }

          • 2. Re: Tween executing but not displaying any change
            aditi_bk Level 1

            Hi Ned,

             

            The trace was showing that the tween did actually finish, but _alpha was still 0, so I did a folioholderDark.start(), within the onMotionFinished function, if _alpha was 0, with a counter [in case of an infinite loop], and that seems to have fixed it. I don't know how the tween could finish and not reset _alpha..but apparently it was....

             

            Now the new problem is that when I try to a _xscale, the tween once again finishes [onMotionFinished is called], but I don't see anything. But this time, I could not check if the mc._width had changed or not, as the trace says this value is undefined within the onMotionFinished function.....:(...and the code is SO simple...

             

            trace("sun valuesorg : " + this.sun._width + " : " + this.sun._height);  //Shows correct values


            var bigsunScaleX:Tween = new Tween(this.sun, "_xscale",Bounce.easeOut, 100, 15, 1,true);

            var bigsunScaleY:Tween = new Tween(this.sun, "_yscale",Bounce.easeOut, 100, 15, 1,true);


            bigsunScaleX.onMotionFinished = function() {


            trace("sun values : " + this.sun._width + " : " + this.sun._height);  //Values undefined....??


            trace("big sun out");        //can see this trace message


            }

            • 3. Re: Tween executing but not displaying any change
              aditi_bk Level 1

              Hi Ned,

               

              I fixed it...well actually I found out what was wrong....it was such a stupid mistake that I really should go live under a rock now, far away from computers...I had actually left a one extra frame within the file, so the time line kept moving....so I could not see the clip scale..though this was only with the sun clip...:| thanks for your help though...:)

              • 4. Re: Tween executing but not displaying any change
                aditi_bk Level 1

                Ok, I was too quick to rejoice...I am trying to do a series of events using tweens, sometimes they get executed, sometimes only the onMotionFinished function gets executed, sometimes nothing happens....:(..I am redoing a section of my website using actionscript instead of actual tweens...this is my code so far...

                 

                 

                import mx.transitions.Tween;

                import mx.transitions.easing.*;

                stop();

                 

                var n3bbShow:Tween;

                var n2bbShow:Tween;

                var n1Fall:Tween;

                var n1bbShow:Tween;

                var abtShow:Tween;

                var cntShow:Tween;

                var wrkShow:Tween ;

                var n3bbHide:Tween;

                var n2bbHide:Tween;

                var n1bbHide:Tween;

                 

                trace("in frame 2");

                trace("sun valuesorg : " + this.sun._width + " : " + this.sun._height);

                 

                var bigsunScaleX:Tween = new Tween(this.sun, "_xscale",Bounce.easeOut, 100, 10, 1,true);

                var bigsunScaleY:Tween = new Tween(this.sun, "_yscale",Bounce.easeOut, 100, 10, 1,true);

                var bigsunMoveX:Tween = new Tween(this.sun, "_x", Regular.easeIn, this.sun._x, 67, 1, true);

                var bigsunMoveY:Tween = new Tween(this.sun, "_y", Regular.easeIn, this.sun._y, 170, 1, true);

                 

                bigsunMoveY.onMotionFinished = function() {

                 

                n3bbShow = new Tween(n3bubble,"_alpha", Regular.easeIn, 0, 100, 1,true);  //till this point everything works but nothing happens after that..

                 

                }

                 

                n3bbShow.onMotionFinished = function(){

                trace("in n2speechBubble funtn");

                 

                n2bbShow = new Tween(n2bubble,"_alpha", Regular.easeIn, 0, 100, 1,true);

                 

                }

                 

                n2bbShow.onMotionFinished = function(){

                 

                if(this.n2bubble._alpha == 0){ n2bbShow.start();}    //tried the old fix..but no luck

                 

                n1Fall = new Tween(ninja1,"_y", Bounce.easeOut, -15, 567, 3,true);

                }

                 

                n1Fall.onMotionFinished = function(){

                trace("in n1speechBubble funtn");

                n1bbShow = new Tween(panic,"_alpha", Regular.easeIn, 0, 100, 1,true);

                }

                 

                n1bbShow.onMotionFinished = function(){

                trace("in buttonShow funtn");

                abtShow = new Tween(about,"_alpha", Regular.easeIn, 0, 100, 2,true);

                cntShow = new Tween(contact,"_alpha", Regular.easeIn, 0, 100, 2,true);

                wrkShow = new Tween(work,"_alpha", Regular.easeIn, 0, 100, 1,true);

                n3bbHide = new Tween(n3bubble,"_alpha", Regular.easeIn, 100, 0, 1,true);

                n2bbHide = new Tween(n2bubble,"_alpha", Regular.easeIn, 100, 0, 1,true);

                n1bbHide = new Tween(panic,"_alpha", Regular.easeIn, 100, 0, 1,true);

                }

                • 5. Re: Tween executing but not displaying any change
                  aditi_bk Level 1

                  Ok once again...my bad...I am guess it is a scope issue again, all the tweens defined within the function probably don't survive outside, even though I declared them out side, meaning this should not have happened..but I dnt know actionscript 2 all that well...so I put the onmotionfinished inside and now it worked...