Am Creating a game in as2 an object come from left to right Randomly how do i stop the object i written script in single frame but it runs in all frame of the game
_root.onEnterFrame = function() {
passed++;
if (passed>speed) {
passed = -1;
collect = root.attachMovie(“pea”, "pea"+placed, _root.getNextHighestDepth(), {_y:Math.random((0.001))250});
collect.gotoAndStop(Math.floor(Math.random()collect._totalframes)+1);
collect.angle = Math.abs(0);
collect.xspeed = velocityMath.cos(0);
collect.yspeed = velocityMath.sin(0);
collect.onEnterFrame = function() {
this._x += this.xspeed;
this._y += this.yspeed;
x_dist = this._x-player1._x;
y_dist = this._y-player1._y;
if (this._x<0) {
this._x = 0;
this.xspeed *= -1;
}