Here is a quick code I made to simulate a typewriter effect where each letter of a string is written out onto a dynamic text field, the example seen here. This tutorial employs from AS: Functions by Inglor. Also, I use setInterval in this tutorial which I don't think has been covered in any of the other tutorials. Anyway, here we go!
First step is to open up your Flash and make a dynamic text box. Give this box the instance name of "showtext" (no quotes of course). Simple enough? Next, to complete the effect, we open up our actions panel for the frame we are in and add the following:
text = "This is the typewriter effect in action!";
l = text.length;
p = 1;
function spelltext() {
showtext = text.substring(0, p);
p++;
if (p == l+1) {
clearInterval(write);
}
}
write = setInterval(spelltext, 50);
And viola! A typewriter effect. Just type in whatever you want for your variable "text" to have the effect on it.
However, what is a tutorial if you don't know what you are doing? Here is an explaination of the code:
text = "This is the typewriter effect in action!";
This is where your text variable is declared. Whatever is in the quotes will be "typed" onto the screen in the dynamic text field for the variable "showtext".
l = text.length;
p = 1;
We use the letter l for length of the text, the total number of characters in it. We also use p for the current "position" of the text that is being typed out.
function spelltext() {
showtext = text.substring(0, p);
p++;
if (p == l+1) {
clearInterval(write);
}
}
This makes a new function, named spelltext which will make the new variable, showtext, display from the beginning of our original text to the current position, p. p++ adds one to the current position in the string. if(p == l+1) will check to see if the entire string has been "typed" out. If it has, the interval write will be terminated (see next step).
write = setInterval(spelltext, 50);
This creates an interval for the function "spelltext" so it occurs every 50 milliseconds (the value of milliseconds can be changed to make the typing go faster or slower). The name of the interval is "write", which will be terminated by the "spelltext" function when our entire phrase has been typed.
I think that concludes it. I might make one on setInterval and clearInterval if no one else does.