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

How to use Registration points to stretch and rotate a MovieClip Correctly

New Here ,
Apr 18, 2013 Apr 18, 2013

_trest.jpg

Is kind of an explanation of what I am trying to do.

I have 2 known points, a slope, the angle I want it to rotate to, and the hypotenuse.

I've spent at least an hour trying different things, and googling.

Any idea on what I should do? Currently just setting the width larger, and then using .rotation.

Thanks.

TOPICS
ActionScript
513
Translate
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

correct answers 1 Correct answer

Community Expert , Apr 18, 2013 Apr 18, 2013

use a top center reg point.  assign your circle's x,y to match the upper point's x,y.  then assign the circle's width and height to be distance between the two points and finally its rotation to be the atan2 between the two points:

circle_mc.x = p1.x;

circle_mc.y = p1.y;

circle_mc.width = circle_mc.height = Math.sqrt((p2.y-p1.y)*(p2.y-p1.y)+(p2.x-p1.x)*(p2.x-p1.x));

circle_mc.rotation = -90+ 180*Math.atan2(p2.y-p1.y,p2.x-p1.x)/Math.PI;

Translate
Community Expert ,
Apr 18, 2013 Apr 18, 2013

use a top center reg point.  assign your circle's x,y to match the upper point's x,y.  then assign the circle's width and height to be distance between the two points and finally its rotation to be the atan2 between the two points:

circle_mc.x = p1.x;

circle_mc.y = p1.y;

circle_mc.width = circle_mc.height = Math.sqrt((p2.y-p1.y)*(p2.y-p1.y)+(p2.x-p1.x)*(p2.x-p1.x));

circle_mc.rotation = -90+ 180*Math.atan2(p2.y-p1.y,p2.x-p1.x)/Math.PI;

Translate
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 ,
Apr 18, 2013 Apr 18, 2013

Thank You. That was exactly what I was looking for! Works exactly how I wanted it to.

One thing I removed the mc.width part, it was causing a large circle to be between the points. So I took that out and left it to default.

Translate
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
Community Expert ,
Apr 18, 2013 Apr 18, 2013
LATEST

you're welcome.

Translate
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