PDA

View Full Version : Random _x Movement


tranterra
05-05-2001, 06:54 PM
I read the "Actionscripted Movement" tutorial, d/led the .zip and was able to modify the actionscript so that it moved my object - white - to a random _x position.

It worked great for the first object, but when I tried to apply it to other objects, both the first object and the other objects moved in unison.

What do I need to change when I apply it to other objects so they move to different random places?

Here's my modified code as seen in the "controller" movie clip for my oject, white:
----------------------------------------
Frame 1:
loops = 0;
_root:target_x = random(300) + 25;
_root:xdiv = (_root:target_x-_root.white._x)/10;
----------------------------------------
Frame 2:
loops = loops+1;
_root.white._x = _root.white._x+_root:xdiv;
----------------------------------------
Frame 3:
loops = loops+1;
_root.white._x = _root.white._x+_root:xdiv;
if (loops < 10) {
gotoAndPlay (2);
} else {
gotoAndPlay (1);
}
----------------------------------------

Any help would be appreciated. Thanks.

//: tranterra :\\

P.S. if you want to see the messed up movie, just go to http://www.tranterra.com and click the "vr2" link at the bottom of the page. It sorta' blends in, so look close. Sorry for how bad the first page looks, I'm still working on it.

Jesse
05-06-2001, 08:19 AM
You have to make another controller for each extra object, not the best way, but the tutorial was only designed for one object, here's the source I posted for a similar question a while ago:

http://www.actionscripts.org/help/tranterra/

Cheers

Jesse

tranterra
05-06-2001, 03:09 PM
That helped. I had made another controller, but I still couldn't get them to do what I needed them to. I have it figured out now.

Thanks again.

//: tranterra :\\