
May 18th, 2005, 11:02 AM
|
|
Contributing User
|
|
Join Date: Aug 2004
Posts: 34
Time spent in forums: 3 h 3 m 48 sec
Reputation Power: 5
|
|
how to make a 'for'-loop wait ??
hi there,
i wrote an AS function to draw a circle. the function offers the opportunity to choose in how many parts it is drawn.
it only works for an even number of parts starting at 8. but that's not my concern; i'm working on that.
the problem is the following : i used a 'for' loop to draw the different parts of the circle. what i want is that the routine waits when it has done a loop before continuing to the next (i hope i make myself clear; i'm not native english speaking).
here's the code :
Code:
MovieClip.prototype.drawCircle = function(r, x, y, parts) {
this.moveTo(x+r, y);
a = Math.tan(((360/2)/parts) * Math.PI/180);
for (var angle = 360/parts; angle<=360; angle += 360/parts) {
var endx = r*Math.cos(angle*Math.PI/180);
var endy = r*Math.sin(angle*Math.PI/180);
var cx =endx + r*a*Math.cos((angle-90)*Math.PI/180);
var cy =endy + r*a*Math.sin((angle-90)*Math.PI/180);
this.lineStyle(1, 0x000000, 100);
this.curveTo(cx+x, cy+y, endx+x, endy+y);
//here i want the loop to wait for a while
}
}
var c80 = this.createEmptyMovieClip("c", 1);
c80.drawCircle(100, 200, 200, 40);
i suspect it's very easy but i don't know how to do it. something with setInterval? but how?
thnx in advance,
grenouille.
|