jonnooe
May 9th, 2003, 12:20 AM
im trying to create a random moving line along the x-coordinate that with each cycle will move for a random distance at a random speed. i can generate the ranom distance and speed just fine, but i cant get the speed to apply the movement for then length of the distance. i have tried using a for loop:
for(i = 0; i < distance/speed; i++) but that creates an extremely fast and rough movement. i need a slow and smooth movement.
any help would be greatly appreciated. here is my code:
onClipEvent (enterFrame) {
speed = -20 + math.random() * (20 + 20);
distance = 50 + math.random() * (300 - 50);
for(i = 0; i < distance/speed; i++){
_x += speed;
}
}
for(i = 0; i < distance/speed; i++) but that creates an extremely fast and rough movement. i need a slow and smooth movement.
any help would be greatly appreciated. here is my code:
onClipEvent (enterFrame) {
speed = -20 + math.random() * (20 + 20);
distance = 50 + math.random() * (300 - 50);
for(i = 0; i < distance/speed; i++){
_x += speed;
}
}