flash actionscript:
Seems I can never keep setInveral straight in my head. I've managed the code below but the action still isn't what I have planned. Basically, all I want is for a _mc to be duplicated and start a random motion ...in a timed interval. Every second or so, a new _mc is created and shot out into the stage for its random motion path. I guess you might visualize it as a really crummy particle spray? anyway, the code is below. thanks in advance for any suggestions that may come. Some characters may drop from my copy/paste into this thread (well, it use to do that a few months back. maybe it's fine now) but the code in general is working. All except for the fact my clips are duplicating at the same time as opposed to one after another. click click click :) noel function myMotion() { this.onEnterFrame = function(){ this.xpos += Math.floor(Math.random(5)*3)-2; this.ypos += Math.floor(Math.random(5)*2)-2; this._x += this.xpos; this._y += this.ypos; } } circ1_mc._visible = 0; function circWait() { for (i=1; i<=6; i++) { circ1_mc.duplicateMovieClip("circ" +i+ "_mc", i, circ1_mc); myMotion.call(eval("circ" +i+ "_mc")); trace("circ"+i+"_mc"); } clearInterval(myInterval); } myInterval = setInterval(circWait, 400);
The problem is the 'for' loop. For loops occur all at the same time, so it's creating 6 movie clips and it's done. remove the for loop and it should work. If you only want 6 of them, you should put a counter++ inside the circWait() function followed by if(counter==6){ clearInterval(myInterval); } Hope that helps!
Don't see what you're looking for? Try a search.
|