Skip to main content
October 13, 2009
Question

Random Object Movement

  • October 13, 2009
  • 1 reply
  • 826 views

Hey everyone,

I have a flash programming research assignment using AS3.

The assignment is to create a random object that moves in a direction upon testing movie. After 2-3 seconds the object needs to change random directions.

Any bits of code or help you all can give would be very appreciated.

Thanks,

Wolfordsworks

This topic has been closed for replies.

1 reply

October 13, 2009

Since you said this is a research assignment I'm not going to write the code for you but I'll tell you what to do.

Create a function that gets called using time interval (your 2-3 seconds)...see the Flash help docs to see how to do this.

Within the function use the tween class to set and tween the x and y of your object.  The values of the x and y can be set to a random number using Math.random();

Again more information and samples on these functions can be found in the flash help docs.

Regards,

Dan.

http://www.dsmith.tv

http://www.smithmediafusion.com/blog