As3 get WIDTH and HEIGHT of scaled / resized – movieClip / mc

actionscript-3flashheightscalewidth

I am scaling a movieClip often and need to place it on the screen in certain places according to its size.

Once scaled, how can I get the WIDTH and HEIGHT of a movie clip?

trace(my_mc.width); /// would equal 333

/// This code makes my movie clip fit in the correct proportions. 
my_mc.height = stage.stageHeight;
my_mc.scaleX = my_mc.scaleY;

/// Its been resized!
trace(my_mc.width); /// STILL equals 333

..

Any ideas how to get new width and height?

Best Answer

You're probably experiencing stage scaling issues.

If you're dependent on stage size, set:

import flash.display.StageAlign;
import flash.display.StageScaleMode;

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

Your provided example doesn't encapsulate the problem. It works as expected.

size scale

Also possible is timing of your trace statements, if you're doing frame-based animation. Perhaps you're viewing an artifact of size instead of in line with the lifecycle you expect.

Related Topic