hi..here is a second revision I did... using two buttons to control the sopping and starting of the 'bounce' animation:
Code:
onClipEvent (load) {
speed = 25;
angle = random(360);
_root.centerMode = false;
speedX = Math.cos(angle*Math.PI/180)*speed;
speedY = Math.sin(angle*Math.PI/180)*speed;
}
onClipEvent (enterFrame) {
if(_root.centerMode == false) {
this._x += speedX;
this._y += speedY;
if (this._x >= (Stage.width - this._height/2)) {
speedX = -speedX;
} else if (this._x <= (0 + this._height/2)) {
speedX = -speedX;
} if (this._y >= (Stage.height - this._height/2)) {
speedY = -speedY;
} else if (this._y <= (0 + this._height/2)) {
speedY = -speedY;
}
}else if(_root.centerMode == true) {
this._x -= (this._x - _root.goTo_x)/6;
this._y -= (this._y - _root.goTo_y)/6;
}
}
/*onClipEvent (mouseUp) {
centerMode = true;
_root.goTo_x = 300;
_root.goTo_y = 400;
speed = 0;
angle = 0;
speedX = 0;
speedY = 0;
}*/
and of the two buttons I have this code:
Code:
on (press) {
_root.centerMode = false;
}
and
Code:
on (press) {
_root.centerMode = true;
_root.goTo_x = Stage.width/2;
_root.goTo_y = Stage.height/2;
/*
_root.goTo_x = 300;
_root.goTo_y = 400;
*/
}
this way you can stop and start it whenever.. (I just moved it to a button event for testing purposes)