1. Computing

Creating Random Motion with Flash ActionScripts and Math.random

By

The Math object is a function of Flash that lets you use various mathematical constants and functions as part of your animation. There are many uses of the Math function, from Math.ceil – which rounds a decimal number up to the nearest whole integer – to Math.max, which compares two integers and returns the largest of them, but today we’re going to work with Math.random.

Math.random generates a random number between 0.0 and 1.0, which you can use for any number of purposes. One of its best uses is to create animations with unguided motion that still operates within specific parameters.

Let’s try animating a basic object using random motion. Start off by drawing a shape on your stage, and converting it to a symbol (F8).

©2014 About.com. All rights reserved.