I have problem when dealing with transform in Flash cs4 ....
When I rotate my movieclip and trace the output, my movieclip's width also changed....
I have problem when dealing with transform in Flash cs4 ....
When I rotate my movieclip and trace the output, my movieclip's width also changed....
I'm not sure why this is a problem - it's expected behavior. The width of a clip is the actual number of pixels from the left most edge to the right most edge - which will change if a clip is rotated. If your clip has a sub-clip within it, that clip's width will not change, since presumably it's rotation isn't changing.
This is a bug in flash player. There are a few things you can do:
Option 1 (probably the best way):
Create a subclass of MovieClip and override the get and set methods for width and height. Have the setters call super, and store the values as private variables (eg _width/_height) When get is called, return your private variables. Since you are using a matrix, override the get and set matrix functions, set the scaling factors with your new functions, and set them to not scale before calling super. Why this works: The setters are not affected by this bug.
Option 2:
Use scaleX/scaleY instead for getting the width/height, and multiply by the width and height values for 0 rotation, 1.0 scale. Why this works: The scaleX/scaleY are not affected by this bug.
Happy Coding!
width/height will change as you rotate the clip. if you don't want this behaviour, use the scaleX/scaleY properties instead.
OK .. MY BAD.. I've seen my error eventually :). I was convinced this was a bug before. Though Branden was right, I still find it pretty confusing. This is eventually an example to show that Branden was right and there is no discrepancy between the last 2 values.
var box = new Sprite();
box.graphics.beginFill(0xFF0000);
box.graphics.drawRect(0, 0, 100, 100);
this.addChild(box);
trace(box.width);
box.rotation = 45;
trace(box.width);
box.width = 141.4;
trace(box.width);
Edit: You'd still might want to check PiPeep's link form grantskinner describing something like I wanted to prove above, but successuly (in Flash CS3 - AS3) - http://www.gskinner.com/blog/archives/2007/08/annoying%5Fas3%5Fbu.html