Highlighted

Setting width before or after rotation doesn't give same result

New Here ,
Dec 11, 2018

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);

TOPICS
Discussions

Views

41

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Setting width before or after rotation doesn't give same result

New Here ,
Dec 11, 2018

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);

TOPICS
Discussions

Views

42

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 11, 2018 0
Adobe Employee ,
Dec 12, 2018

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 12, 2018 0
Adobe Community Professional ,
Dec 12, 2018

Copy link to clipboard

Copied

Try setting the x scale instead of the width.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 12, 2018 1
Pioo LATEST
New Here ,
Dec 12, 2018

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)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 12, 2018 0