Copy link to clipboard
Copied
Hi,
I got a blue square clip (50x50), I wanna transform it to be 100x50 and 45° rotated.
When I set the width before the rotation no problem, but when I set the rotation first my clip is shorter than 100px...
Why is that?
var clip:Sprite=new Sprite();
var clip2:Sprite=new Sprite();
var shape=new Shape();
shape.graphics.beginFill(0x0000FF);
shape.graphics.drawRect(0, 0, 50,50);
shape.graphics.endFill();
var shape2=new Shape();
shape2.graphics.beginFill(0x0000FF);
shape2.graphics.drawRect(0, 0, 50,50);
shape2.graphics.endFill();
clip.addChild(shape);
clip2.addChild(shape2);
this.addChild(clip);
this.addChild(clip2);
clip.y=clip2.y=400;
clip.x=250;
clip2.x=400;
clip.rotation=45;
clip.width=100;
clip2.width=100;
clip2.rotation=45;
trace(clip.width);
trace(clip2.width);
Copy link to clipboard
Copied
Not an expert, but found a discussion that could probably provide you with insights actionscript 3 - Setting movieClip width and height fails - Stack Overflow
Thanks,
Preran
Copy link to clipboard
Copied
Try setting the x scale instead of the width.
Copy link to clipboard
Copied
Actually I found out this behaviour explanation..
When a clip is rotated its dimension change, and when you set the width or height it just set the scale accordingly to its current dimension.
In my case :
this.addChild(clip); //Width :50
clip.rotation=45; //Width : 70.7
clip.width=100; // -> clip.scaleX = 1.4 (100/70.7)
//Width : 85.35 (not 100)