Hi - in my flash site im creating i have a certain area which i call an effect box/area and in it is just going to be funny stupid little effects.
Anyway i have script to make an object move randomly around; except i do not know how to make it so that the effect is in my effect box/area instead of all over my site?? i have played around with the width and height varibles but just cant get it to work???
Here is my script:
onClipEvent (load) {
//data you may want to change
width = 600;
height = 600;
speed = Math.round(Math.random()*2)+1;
//initial positions
x = Math.random()*width;
y = Math.random()*height;
this._x = x;
this._y = y;
x_new = Math.random()*width;
y_new = Math.random()height;
}
onClipEvent (enterFrame) {
//x movement
if (x_new>this._x) {
sign_x = 1;
} else {
sign_x = -1;
}
dx = Math.abs(x_new-this._x);
if ((dx>speed) || (dx<-speed)) {
this._x += sign_xspeed;
} else {
x_new = Math.random()width;
}
//y movement
if (y_new>this._y) {
sign_y = 1;
} else {
sign_y = -1;
}
dy = Math.abs(y_new-this._y);
if ((dy>speed) || (dy<-speed)) {
this._y += sign_yspeed;
} else {
y_new = Math.random()*height;
}
}