|
-
Need to randomly make a MC "hover" on the X/Y co-ords
I have great scripts for dynamically growing and shrinking a MovieClip with a fair amount of elasticity, but what I need now is to have several MovieClips "hover" in place on the X/Y axis with random movements, and with the movement easing in and out.
Am I making sense? Does anyone have a script for such movement handy?
Thanks in advance.
-
code:
onClipEvent (load) {
speed = 1;
delay = 10;
moveDistance = 80;
// Adjust above
Xpos = _x;
Ypos = _y;
timer = 0;
}
onClipEvent (enterFrame) {
timer = timer+speed;
if (timer>delay) {
Xpos = _x+Math.random()*moveDistance*-1+moveDistance/2;
Ypos = _y+Math.random()*moveDistance*-1+moveDistance/2;
timer = 0;
}
_x += (Xpos-_x)/7;
_y += (Ypos-_y)/7;
}
I wrote it so you can adjust the maximum distance it moves, the delay, and the speed.
-joe
Last edited by FlashGod.com; 09-20-2004 at 08:36 PM.
_

__________________
-
Very cool! It works as advertised - thank you very much.
Do you know how this could be altered so that the "hovering" item moved from a set position, so that if it began in position (20,20) it would move randomly from there, move back to (20,20), and then another random movement and so on?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|