PDA

View Full Version : random 'y' movement



suha
May 8th, 2003, 06:04 AM
i've applied the following script to a movieclip to change its 'y' coordinate randomly at run time and it works fine but i'm also trying to control the maximum 'top' and maximum bottom 'y' movement for which the value should be: top = 40 and bottom = 400. so it only displays randomly between 40 to 400 'y' coordinate. could you tell me how can i implement this in the following script?

----------------------------------------

onClipEvent (enterFrame) {

_x -= 4;
if (_x<=-2247) {
_y = Math.random()*300;
_x = 1024;
}
}

kode
May 8th, 2003, 06:07 AM
welcome, suha. =)

_y = 40+Math.random()*(400-40);
;)

suha
May 8th, 2003, 06:40 AM
working fine. cheers. much appreciated.

kode
May 8th, 2003, 06:42 AM
de nada. :P =)