Date: 2007-04-09
Hits: 10505
Rate:

email to friends
printFlash Text Effect using Radomizer Tutorial
Hello again,
Today’s tutorial is about some neat actionScript driven text effect, I like to call it the “brute forced” text effect.
The basic effect we’re looking to achieve is to force each letter of the desired text to change taking every possible value till it ends up having the correct value it should take and then stopping it at that value and continuing with the following letter.
Well try our best to make the effect fully customizable, scalable and reusable. Below is that we are going to achieve at the end of this flash tutorial.
For that purpose, start a new flash document, let it have the following properties :
Width :375 , height: 60, background color : black and frame rate : 12 (figure 1).
Now, as always, lock the actions layer so that you wouldn’t accidentally place any content in it (separating visual content from code) and add whatever you like as background in a separate, base layer.
Now for the important part :
Add a new layer above the background layer, add a dynamic text field to this layer, and give it the instance name of "dt". Select “Courrier New “ as font and set the font size to 24 and the font color to white. You could also at this point add some drop shadow or glow effect to the text if you like (figure 2).
Type in some texts just to see how it would look (I’ve typed the two words Sample Text). And this concludes the design part, now for the coding part:
Let’s first think and write our pseudo code:
We should start by specifying what the final text would be; we’ll store this text in a variable called desiredText. We will also initialize the "dt" dynamic text to have no text in it by assigning its text property the value of " " (an empty string).
The code to do that is very simple :
Now we would like to have the dt field show the first letter, which is an “C” after shuffling through several values, we would also want this to reoccur for the remaining letters of the sentence CambodiaXP Flash!.
In order to achieve that, we would start by constructing a function that will randomize the letters one after the other till the correct letter is met; we will call this function every 10 milliseconds using the setInterval method and once all the letters have appeared correctly we will simply clear the interval to stop calling the function.
So the core of this effect is in fact this function itself, we’ll call it randomize();
Here’s what this function will look like :


