A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Finding centre coordinates of a circle

Threaded View

  1. #5
    Member
    Join Date
    Feb 2010
    Posts
    59
    The formula for a circle:

    (x-h)^2+(y-k)^2=r^2

    (h,k) is the center

    r is the radius

    You will need to know the distance formula too:

    d= sqrt[(x2-x1)^2+(y2-y1)^2]

    p1= (x1,y1)

    p2 is (x2,y2)

    p1 means "first point"
    p2 means "second point"




    The distance between two points is the squaroot of the square of the differnce of the x values of the points minus the square of the difference of the y values of the points.

    Now I will try to help you with your problem:

    You can use:

    trace(obj.x)

    to see the object's x position and:

    trace(obj.y)

    to get the objects y position. This should give you a point (x,y) which should be the center of the object.

    To get the center of your stage you just take the width and divide by 2 and the same with the height. All you have to do is make your object's x and y position match the stage's center
    Last edited by Suthers; 04-20-2010 at 01:50 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center