alg205
asked on
How do I stop a looping function in actionscript 2.0
Hey all! I am a complete newbie when it comes to actionscripting. I followed a tutorial that creates falling snowflakes. The movie works fine by itself but my problem comes in when I copy the movie as a scene into another flash that has individual scenes as "commercials." When I run the movie, the snowflakes continue to fall throughout the other scenes. I know that I somehow have to stop the loop but I'm not sure how. I want it to just play for that scene (I have the background set to stop at 180 frames) I've tried looking at other posts and searching the internet and I think that I need to use clearInterval but I'm not sure where to put it or the exact syntax of how to write it. I understand what is written but not how to change it.
Any help is GREATLY appreciated!!! Thanks!!!
Any help is GREATLY appreciated!!! Thanks!!!
Here is my code:
this.createEmptyMovieClip("canvas_mc",10);
var i = 0;
myInterval = setInterval(addFlake,500);
function addFlake() {
if (i<20) {
var t:MovieClip = canvas_mc.attachMovie("snowflake","flake"+i,canvas _mc.getNextHighestDepth());
i++;
t._xscale = t._yscale = Math.random()*80+20;
t._x = Math.random()*Stage.width;
t._y = -50;
t._alpha = Math.random()*40+50;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER