Skip navigation
Currently Being Moderated

starting a scale tween from current dimensions

Jan 8, 2014 11:40 AM

Hi All,

This is straight forward but I'm probably using wrong terms when searching help files:

 

I have a movie clip that has a width and height of 300 x 150 on the stage. I zoom that (expand that to about double those dimensions) at runtime with this tween code:

var scaleXTween:Tween=new Tween(animImgMC,"scaleX",Bounce.easeOut, 1,2,2.4,true);

var scaleYTween:Tween=new Tween(animImgMC,"scaleY",Bounce.easeOut, 1,2,2.4,true);

When I hit a button after that zoom happened, I want that movie clip to zoom back to its original dimensions *from the current zoomed dimensions.* (So IOW: from its zoomed 600 x 300 size it tweens back down to 300 x 150.)  I'm trying to use the code below but, of course, that makes the MC first jump back to the original 300 x 150 dimension and then shrink from there.

var scaleXTween:Tween=new Tween(animImgMC,"scaleX",None.easeNone, 1,.6,3,true);

var scaleYTween:Tween=new Tween(animImgMC,"scaleY",None.easeNone, 1,.6,3,true);

How do I use the above tween code to start scaling down from the current animImgMC.width and animImgMC.height?

 

Thanks

 
Replies
  • Currently Being Moderated
    Jan 8, 2014 11:46 AM   in reply to paul_james123

    Just use the same scaleX and scaleY properties for the starting pooints when you want to scale back down and specify the end value as 1.

     

    var scaleXTween:Tween=new Tween(animImgMC,"scaleX",None.easeNone, animImgMC.scaleX,1,3,true);

    var scaleYTween:Tween=new Tween(animImgMC,"scaleY",None.easeNone, animImgMC.scaleY,1,3,true);

     

    but do not declare another set of varioables with the same variable name.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 8, 2014 1:41 PM   in reply to paul_james123

    You showed two sets of

     

    var scaleXTween

    var scaleYTween

     

    the "var" part should only happen once for each, otherwise you are declaring them multiple times.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 8, 2014 3:14 PM   in reply to paul_james123

    The problem is with using the term "var" more than once.  The first time you use it should be the only time you use it.  The variable itself can be reused as often as you like, but when you precede it with the word "var" you are declaring a it again.

     

    What you could do....

     

    var scaleXTween:Tween=new Tween(animImgMC,"scaleX",Bounce.easeOut, 1,2,2.4,true);

    var scaleYTween:Tween=new Tween(animImgMC,"scaleY",Bounce.easeOut, 1,2,2.4,true);

    scaleXTween:Tween=new Tween(animImgMC,"scaleX",None.easeNone, 1,.6,3,true);

    scaleYTween:Tween=new Tween(animImgMC,"scaleY",None.easeNone, 1,.6,3,true);

     

    notice how "var" is not used again the second time.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 9, 2014 7:15 AM   in reply to paul_james123

    You're welcome Paul

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 10, 2014 10:54 AM   in reply to paul_james123

    I missed removing another party as well.  The second time around do not use " :Tween " as well.

     

    var scaleXTween:Tween=new Tween(animImgMC,"scaleX",Bounce.easeOut, 1,2,2.4,true);

    var scaleYTween:Tween=new Tween(animImgMC,"scaleY",Bounce.easeOut, 1,2,2.4,true);

    scaleXTween = new Tween(animImgMC,"scaleX",None.easeNone, 1,.6,3,true);

    scaleYTween = new Tween(animImgMC,"scaleY",None.easeNone, 1,.6,3,true);

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 10, 2014 12:58 PM   in reply to paul_james123

    Actually, inside the function you could redeclare the variable (var ...:Tween), but it is no longer the same variable and only has scope within the function.  I don't think you need/want it to be a different variable though.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points