• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Dec 11, 2018 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);

Views

137

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
community guidelines
Adobe Employee ,
Dec 12, 2018 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

Votes

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
community guidelines
LEGEND ,
Dec 12, 2018 Dec 12, 2018

Copy link to clipboard

Copied

Try setting the x scale instead of the width.

Votes

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
community guidelines
New Here ,
Dec 12, 2018 Dec 12, 2018

Copy link to clipboard

Copied

LATEST

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)

Votes

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
community guidelines