Particle trouble

I’m trying to create some simple particle effects here. When the animation in the particle has finished in each particle would like to remove it or replace with new ones. Maybe I need to add actionscript to the end of the timeline (of the particle)?

Not sure what script would be. something like _root.function particles(remove). I don’t know , that was probably a bad guess and extremely sloppy syntax.

var i:Number = 1;
setInterval(particles, 120);

function particles() {
if (i < 50) {
var myClip:MovieClip = mytarget.attachMovie(“anim”, “anim”+ i, i);
myClip._x = random(mytarget._width - myClip._width);
myClip._y = random(mytarget._height - myClip._height);
i++;
//myClip.blendMode = invert;
setInterval(particles);
}
else if (i > 0) {
i–;
yourMessage.removeMovieClip();

}

};