A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: 8 shape loop

  1. #1
    Member
    Join Date
    Jan 2001
    Posts
    83

    8 shape loop

    how do i create a ball to circulate in a 8 shape loop using script. Hence the ball will move in a continuous loop.

  2. #2
    Senior Member
    Join Date
    Mar 2000
    Posts
    177
    You can use the equation for a lemniscate (parametric form):

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

    Translated to ActionScript, this should get you started:

    Code:
    // 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;
    };
    New Book: Robert Penner's Programming Flash MX
    Dynamic tweening, color, math, vectors and physics with OOP ActionScript
    http://www.robertpenner.com/profmx
    http://www.amazon.com/exec/obidos/AS...bertpennerc-20

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