Richard Richard - 5 months ago 26
ActionScript Question

Actionscript 3, What is the difference is between scale and dimension

I'd like to know if I change the scale value, what happened to the object? I'm using flash air system.

I draw a movie clip box with 1000 x 1000px dimension.

I might change the size with 2 ways :

1st : Control of dimension with mc.with or mc.height
2nd : Control of dimension with mc.scaleX or mc.scaleY

Once I try to change the object with 500 x 500px,
Which one do you prefer : mc.width = mc.height = 500 vs mc.scaleX = mc.scaleY = 0.5

What is the benefit of using scale method?


Some good reading in the documentation here.

Basically they do exactly the same thing. It just depends on the case which one is easier for the developer to define in that case. If you know you need the result to be as wide as 212 pixels or the same width as object1 it makes sense to say

object2.width = 212;


object2.width = object1.width;

Let's assume you prefer to keep object2's dimensions proportional. You could then say

object2.scaleY = object2.scaleX;

without even knowing how many pixels that is or having another object of that same height to set it to.

The final note is this: if you change scale, dimension changes, and when you change dimension, scale also does change. In other words, setting scaleX to 1 will also set it back to its original width. Use them interchangeably. Use the one that is simpler for you in that instance.