PDA

Click to See Complete Forum and Search --> : 8 shape loop



flashdiscovery
10-25-2002, 05:49 AM
how do i create a ball to circulate in a 8 shape loop using script. Hence the ball will move in a continuous loop.

robertpenner
11-04-2002, 08:18 PM
You can use the equation for a lemniscate (parametric form):

http://mathworld.wolfram.com/Lemniscate.html

Translated to ActionScript, this should get you started:



// put a "ball" movie clip on timeline
this.size = 150;
this.centerX = 200;
this.centerY = 200;

this.onEnterFrame = function () {
this.t += .1;
var ct = Math.cos(t);
var st = Math.sin(t);
var denom = (1 + st*st);
ball._x = this.centerX + (this.size * ct) / denom;
ball._y = this.centerY + (this.size * ct * st) / denom;
};