AS3: scaling from one side

i attched fla that contain one button
i used tween class to scale the button when the user click the button.

is there any way to scale the button from one side only, if you click the button you will notice it is scaling from top and bottom.

i want to scale it from bottom only

Who is Participating?
tomaugerdotcomConnect With a Mentor Commented:
Nah, that will scale it from the middle (so it will scale up as well as scale down). What the OP is asking for is to scale by just moving the top or the bottom.

The simple solution is that you have to scale AND move the object appropriately. If you're using the tween class to do this you have to set up TWO tweens - one that tweens the scaleY property and the other that tweens the y (position) property.

To figure out what the final (destination) y coordinate should be is easy - if you want it to appear that the object is scaling from the bottom only (only the bottom moves) you move the y coordinate DOWN by HALF the new height of the object minus half of the ORIGINALheight of the object.

var myBtn; // this is where you put a reference to your button component or movieClip

var oldHeight = myBtn.height; // AS3
var newHeight = 300;// I'm making this up of course
var newYPosition = myBtn.y + (newHeight / 2) - (oldHeight / 2);

// and then just set up your two tweens on the object.

Hope this helps.
without looking at your FLA, you would just use the scaleY property in AS 3.0 or the _yscale in AS 2.0...  

rp / ZA
rascalpantsConnect With a Mentor Commented:
the x and y scale are based on scaling compared to the registration point of the movieclip.... which by default is set to the upper left corner... so using code like this...

clip.scaleY = .25;

will make the clip squash down to 25% of the original size, which would make it move the bottom up.

now, in THIS case, the red graphic was created incorrectly, and the inner graphic is positioned in the negative space... I would move it to position 0,0 and readjust the 9 slicing guides again...

then instead of using the "height" property to scale something, I would use the below code instead...

var small:Tween = new Tween(curve_mc, "scaleY", Regular.easeIn,, .25, 0.5,true);

this code will scale by Y 25%
it is never a good idea to use code hacking where standard practice will solve the issue.

rp / ZA

MadkhaliAuthor Commented:
Thanks all :)

i applied scaling and position, it works perfectly

Thanks again
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.