Animation

  1. Home
  2. Computing & Technology
  3. Animation

Creating Random Motion with Flash ActionScripts and Math.random

By Adrien-Luc Sanders, About.com

6 of 8

Do the same with the y position (vertical):

onClipEvent (enterFrame) {
this._x = this._x + Math.random() ;
this._y = this._y + Math.random() ;
}

You now have basic random motion, but it’s not going to do you much good at the moment because the motion is rather on a rather minute level, increasing by less than a pixel in each frame. Let’s move on to the next step to correct that.

6 of 8

Index: Creating Random Motion with Flash ActionScripts and Math.random

  1. Part 1
  2. Part 2
  3. Part 3
  4. Part 4
  5. Part 5
  6. Part 6
  7. Part 7
  8. Part 8

Explore Animation

More from About.com

Animation

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. Creating Random Motion with Flash ActionScripts and Math.random

©2008 About.com, a part of The New York Times Company.

All rights reserved.