Light Ray Effect Help

I am learning action script. I am following the code from a site in which a text has light rays effect. But it the light ray effect is continuing even after the end of the movie. Please help me in stopping the light ray effect of the text. The code for the light ray effect is as follows: i = “1”;
alpha = “0.8”;
maxlight = “20”;
while (Number(i)<=Number(maxlight)) {
duplicateMovieClip (“ray0”, “ray” add i, 800-i);
setProperty ("/ray" add i, _xscale, getProperty("/ray" add (i-1), _xscale)+ialpha);
setProperty ("/ray" add i, _yscale, getProperty("/ray" add (i-1), _yscale)+i
alpha);
setProperty ("/ray" add i, _alpha, 10-i*(0.5/50));
i = Number(i)+1;
}
setProperty (“ray0”, _visible, “0”);
stop ();

Thank You.