I want to have about 15 verticle lines moving randomly along the X axis
Now I have modified the Kirupa random movement tutorial to this code:
onClipEvent (load){
//data you may want to change
width = 300;
speed = Math.round(Math.random()*4)+1;
//initial positions
x = this._x=Math.random()*width;
x_new = Math.random()*width;
}
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_x*speed;
} else {
x_new = Math.random()*width;
}
}
But I noticed the starting point of the verticle line is always in the same spot and is not confined to where I want it positioned…How would I define an exact stage for it be contained in?
Also it goes everywhere on the stage just not what is defined as the width in the begining of the code,
-Case