Código ActionScript :
var pegar=1
quiero simplificar este codigo
y en el movieclip es
Código ActionScript :
onClipEvent (enterFrame) { if (_root.pegar == 1) { myRadians = Math.atan2(_root._r1._y-this._y, _root.r1._x-this._x); // Calculates the mouse angle in radians myDegrees = Math.round((myRadians*180/Math.PI)); // Converts the mouse angle to degrees so it can be expressed in _rotation terms _root.yChange = Math.round(_root.r1._y-this._y); // Calculates the distance between the movie clip and the mouse _root.xChange = Math.round(_root.r1._x-this._x); // Calculates the distance between the movie clip and the mouse _root.yMove = Math.round(_root.yChange/20); // Determines the amount the movie clip should move toward the mouse, grows larger the further the mouse gets from the MC _root.xMove = Math.round(_root.xChange/20); // See above this._y += _root.yMove; //Adds yMove onto the position of the clip (Note: Must be '+=' and not '-=' or else the MC will move away from the mouse, not towards it this._x += _root.xMove; // See above this._rotation = _root.r1._rotation; // Turns the MC to face the mouse if (this.hitTest(_root.r1)) { _root.pegar = 2; } } if (_root.pegar == 2) { myRadians = Math.atan2(_root._r2._y-this._y, _root.r2._x-this._x); // Calculates the mouse angle in radians myDegrees = Math.round((myRadians*180/Math.PI)); // Converts the mouse angle to degrees so it can be expressed in _rotation terms _root.yChange = Math.round(_root.r2._y-this._y); // Calculates the distance between the movie clip and the mouse _root.xChange = Math.round(_root.r2._x-this._x); // Calculates the distance between the movie clip and the mouse _root.yMove = Math.round(_root.yChange/10); // Determines the amount the movie clip should move toward the mouse, grows larger the further the mouse gets from the MC _root.xMove = Math.round(_root.xChange/10); // See above this._y += _root.yMove; //Adds yMove onto the position of the clip (Note: Must be '+=' and not '-=' or else the MC will move away from the mouse, not towards it this._x += _root.xMove; // See above this._rotation = _root.r2._rotation; // Turns the MC to face the mouse if (this.hitTest(_root.r2)) { _root.pegar = 3; } } if (_root.pegar == 3) { myRadians = Math.atan2(_root._r3._y-this._y, _root.r3._x-this._x); // Calculates the mouse angle in radians myDegrees = Math.round((myRadians*180/Math.PI)); // Converts the mouse angle to degrees so it can be expressed in _rotation terms _root.yChange = Math.round(_root.r3._y-this._y); // Calculates the distance between the movie clip and the mouse _root.xChange = Math.round(_root.r3._x-this._x); // Calculates the distance between the movie clip and the mouse _root.yMove = Math.round(_root.yChange/10); // Determines the amount the movie clip should move toward the mouse, grows larger the further the mouse gets from the MC _root.xMove = Math.round(_root.xChange/10); // See above this._y += _root.yMove; //Adds yMove onto the position of the clip (Note: Must be '+=' and not '-=' or else the MC will move away from the mouse, not towards it this._x += _root.xMove; // See above this._rotation = _root.r3._rotation; // Turns the MC to face the mouse if (this.hitTest(_root.r3)) { _root.pegar = 4; } } if (_root.pegar == 4) { myRadians = Math.atan2(_root._r4._y-this._y, _root.r4._x-this._x); // Calculates the mouse angle in radians myDegrees = Math.round((myRadians*180/Math.PI)); // Converts the mouse angle to degrees so it can be expressed in _rotation terms _root.yChange = Math.round(_root.r4._y-this._y); // Calculates the distance between the movie clip and the mouse _root.xChange = Math.round(_root.r4._x-this._x); // Calculates the distance between the movie clip and the mouse _root.yMove = Math.round(_root.yChange/10); // Determines the amount the movie clip should move toward the mouse, grows larger the further the mouse gets from the MC _root.xMove = Math.round(_root.xChange/10); // See above this._y += _root.yMove; //Adds yMove onto the position of the clip (Note: Must be '+=' and not '-=' or else the MC will move away from the mouse, not towards it this._x += _root.xMove; // See above this._rotation = _root.r4._rotation; // Turns the MC to face the mouse if (this.hitTest(_root.r4)) { _root.pegar = 5; } } if (_root.pegar == 5) { myRadians = Math.atan2(_root._r5._y-this._y, _root.r5._x-this._x); // Calculates the mouse angle in radians myDegrees = Math.round((myRadians*180/Math.PI)); // Converts the mouse angle to degrees so it can be expressed in _rotation terms _root.yChange = Math.round(_root.r5._y-this._y); // Calculates the distance between the movie clip and the mouse _root.xChange = Math.round(_root.r5._x-this._x); // Calculates the distance between the movie clip and the mouse _root.yMove = Math.round(_root.yChange/10); // Determines the amount the movie clip should move toward the mouse, grows larger the further the mouse gets from the MC _root.xMove = Math.round(_root.xChange/10); // See above this._y += _root.yMove; //Adds yMove onto the position of the clip (Note: Must be '+=' and not '-=' or else the MC will move away from the mouse, not towards it this._x += _root.xMove; // See above this._rotation = _root.r5._rotation; // Turns the MC to face the mouse if (this.hitTest(_root.r5)) { _root.pegar = 1; } } }