To create a more random animation that makes the box jump all over the screen like someone put itching powder in its pants, set constraints for the motion using the width and height of the stage as maximum allowable values, in which a random value between 0 and the width/height is added to the current x and y position as long as either stays below the max while when it reaches the max, instead a random value between 0 and a chosen number is subtracted.
onClipEvent (enterFrame) {
if (_root.box._x<300&&_root.box._x>0) {
_root.box._x=_root.box_x + Math.random()*300;
}
if (_root.box._x=300) {
_root.box._x=_root.box_x - Math.random()*75;
}
if (_root.box._y<300&&_root.box._y>0) {
_root.box._y=_root.box_y + Math.random()*300;
}
if (_root.box._y=300) {
_root.box._y=_root.box_y - Math.random()*75;
}
}