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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.