Make this script only run for finite number of frames?

Hello I am a total noob,

I saw this example script and got it to work, and I want to use it for only certain frames, but the effect it produces shows in every frame of my show. How can I make it only produce the effect in the frames I want? Thanks in advanced!

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 ();