MovieClip.prototype.getRadian = function() { var mc = this; var y = _root.myText._y-mc._y; var x = random(400)-mc._x; var r = Math.atan2(y, x); return r; }; MovieClip.prototype.setMove = function() { var mc = this; mc._x = random(400); mc._y = random(300); var r = mc.getRadian(); var tx = Math.cos(r)*5; var ty = Math.sin(r)*5; mc.onEnterFrame = function() { mc._x += tx; mc._y += ty; if (_root.myText.hitTest(mc._x, mc._y, true)) { delete mc.onEnterFrame; } if (mc._x>400 || mc._y>300 || mc._x<0 || mc._y<0) { mc.removeMovieClip(); } }; }; var i = 0; function onEnterFrame() { i += 1; var t = mc.duplicateMovieClip("m"+i, i); t.setMove(); if (i>999) { delete this.onEnterFrame; } }