home   |   about   |   time   |   appearance   |   space   |   other   |   tips & tricks    

Since I first started developing flash effects, one of my main concerns was to create movies that don't look the same whenever they open, movies that don't loop and especially clips that resemble to real life events. Take the rain for example, you can never tell what size the drops have, where they will fall or how the wind behaves. To recreate this in Flash we can ignore all these parameters and go for the direct approach. That means drawing a falling drop and duplicating it in different places on the Stage. But a professional developer will always spot the loop, even if you have 1000 drops coming down in the same time. How can you recognize a fake effect? It's simple, keep looking in the same spot for a while and you will see the effect is looping (same drop falls in the same spot).

So we need to add God in the equation. This website presents the easiest way to do that and the featured examples are indicated both to the novices and the more skilled developers. The solution is this simple ActionScript function:

random (value);

"Value" is a integer number (... -3, -2, -1, 0, 1, 2, 3 ...) and the function returns a number (integer) between zero and one less than "value".

Example:

n=random (5);

means "n" can be one of the following numbers {0, 1, 2, 3, 4}

We will use these random generated numbers to trigger different actions in the movie, to establish positions in space and time or to determine different color variations for the objects using specific Flash techniques.

Note: since Flash 5, an alternative function is available: "Math.random();" which returns a floating value between zero and one (0<=value<1). Adobe recommends the usage of this function, but because working with integer numbers is easier and the character of the following lessons is educational, we will use the first (advanced developers might prefer the new one).

Conclusion:

RandomEvent=random(possibilities);

Hope these next examples will help you see the limits of Adobe Flash further than before, and if so, please let us know. Don't forget to check the other WebArticles Flash related sites. And also if you are a beginner, please check these tips and tricks before you start reading the rest.