Letter and Number Rain
| Category | : Flash | Views | : 46766 | ||
| Version | : 8 | Rating | : | ||
| Type | : Text | Source File | : letter-number-rain.zip | ||
| Result | : See the result | ||||
Every wondered how to create Matrix-like animation where the letters and numbers are falling from above? Well, this tutorial is not just about Matrix-like animation. It is more advanced than that. The letters and numbers that are falling also fall in random speed and they are spinning. More like rain actually. Hope you like it.

First create a new document and a new Movie Clip.
Inside the Movie Clip draw a new dynamic text box, instance "letter". You dont need to link a variable to it as we are not going to use that method to change the text.
You can change the color and the size to anything.
Now drag the Movie Clip to the stage with the instance name "letterMC" and paste the actions for the main timeline:
var letter_array = new Array("A", "B", "C",
, "Z",
);
This is the array of character that will appear on the rain; you can add as many characters as you want, for example: "#", "¬", "9", "5", etc.Open the actions for the Movie Clip instance and paste:
onClipEvent(load)
{
//random between 0 and the length of the characters array minus 1.
var index = Math.round(Math.random() * _root.letter_array.length - 1)
//the text that appears on the textbox is equal to the index in the array
this.letter.text = _root.letter_array[index];
//random x between 5 and 545
_x = Math.round(Math.random() * 540) + 5
//random y between -30 and -10
_y = Math.round(Math.random() * -20) - 10;
//the gravity used to make the rain
var gravity = 0.2;
//random number for the scale and the alpha
var ran = Math.round(Math.random() * 50) + 50;
//alpha is ran + 10
_alpha = ran + 10;
//scale the Movie Clip in both x an y using ran
_xscale = _yscale = ran;
//starting speed between 10 and 15, increases with the gravity
speed = Math.round(Math.random() * 5) + 10;
//this is the speed that will make the letter rotate left or right.
//The speed will range from -3 to 3 so if its negative the Movie Clip will
//rotate to the left and if its positive rotate to the right.
rotSpeed = Math.round(Math.random() * 6) - 3;
}
onClipEvent(enterFrame)
{
//Make the Movie Clip go down
_y += speed;
//rotates the Movie Clip left or right
_rotation += rotSpeed
//speed increasing with the gravity
speed += gravity;
if(_y > 410)
{
//if the Movie Clip is out of the screen, remove it.
this.removeMovieClip();
}
}
If you run the movie now you will see only one letter falling, so we need to create more of that.