Wander Motion Class

I recently put together a simple class for managing “wandering” motion in AS3, and thought I would share it. It’s a pretty flexible class, with a lot of different options:

  • specify speed
  • x, y, and rotation targets
  • specify constant trend strength to move towards the target.
  • specify a count and a delayCount to have the trend strength increase over time.
  • outer radius specifies the maximum distance from the x/y target the object can move
  • inner radius specifies when the trend starts (ie. within inner radius, outer radius has no effect)
  • control randomness with varySpeed and varyRotation
  • onChange and onComplete callbacks

Here’s a demo you can use to play with the different settings:

I’ve also been playing around with it to make large generative outputs. Nothing really exciting yet, but it’s fun: image1, image2.

You can grab the Wander class and a simple demo by clicking here. Beware though, you can waste a lot of time tweaking values and watching the results.

Grant Skinner

The "g" in gskinner. Also the "skinner".



  1. Pretty cool. 🙂

    Could it be easily adapted to one of the 3d engines such as away3d, pv3d, sandy etc?

  2. I am not seeing the embedded swf properly. I have the debug player on firefox on mac. It throws lots of errors. The downloaded ones work just fine. Simply excellent.

  3. Hey Max, I was going to ask the same thing. I’ve looked into this and it’s not that straight forward to do this in 3D. You can’t just use SIN and COS on the Z as well as the X & Y. I’d love to know what Math is required to create an orbit in 3D.

  4. Nice job Grant, was just about to do smth like this for myself, but might as well play with your class now 🙂

  5. Nice, very nice. Thanks for sharing.

  6. I imagine this is how particles orbit kind of on quantum level.

  7. Hello

    This is very good post and you have done a great job.I must say that you are very talented.I have checked those both images which you have given and I like it.I can see that demo too.

  8. Hey Guys,

    I wanted to use this class in an AS2 project, so I just ported the code (and test file).

    You can download the files from here: http://qbesq.com/shared/Wander-AS2.zip

    Hope you find it useful.

Leave a Reply

Your email address will not be published. Required fields are marked *