dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Drawing a path circle with actionscript and trigonometria

Threaded View

  1. #1
    Member
    Join Date
    Oct 2000
    Posts
    43

    Drawing a path circle with actionscript and trigonometria

    Hi:

    I want animate a dot following a circle path using action script.

    (Yeah... its easy to draw a circle path and create a motion tween... but i want to animate it using action script)

    Im using this formula:
    * * * * * * * * * * * * * * * * * * * * * * * *


    var r = 150;
    // r is the radius value

    mover = function()
    {
    if( this._x >= -1*r && this._x <= r-1 && this._y >= 0 && this._y <= r)
    // x will increase by 2 if the dot is located
    // at x=-150 and x<149
    // y = 0 and y <= 150
    {
    this._x +=2;
    // increase x by 2 px
    this._y = Math.sqrt ((r*r) - (this._x * this._x));
    // I determine the y position using the trigonometria circle formula
    }
    else
    {
    this._x -=2;
    this._y = (Math.sqrt ((r*r) - (this._x * this._x))) * (-1);
    // I determine the y position using the trigonometria circle formula
    // x will decrease by 2 if the dot is not located
    // at x=-150 and x<149
    // y = 0 and y <= 150

    }

    }

    c1._x = -1*r;
    // The dot is posted at coord x=-150
    c1._y = 0;
    // The dot is posted at Y=0
    c1.onEnterFrame = mover;

    * * * * * * * * * * * * * * * * * * * * * * * *


    The formula works well... more or less...

    check it and see how the dot follow the circle path, put it jumps just in the middle of the circle.
    Attached Files Attached Files

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