Flash Script - Simple Typewriter Effect

This is an article discussion thread for discussing the SitePoint article, “Flash Script - Simple Typewriter Effect

I can’t figure out why this doesn’t work

i’m a flash newbie and came across this tutorial thru yahoo. it works for me after i exported it to swf. try it out.

How can I make a line break? I want to numerate a few things among each other.

i dont know how bad you want to do this but i know a little trick with no code… just --create a movie clip with whatever you want… then you-- type the text that you want to have as a type text effect–ctrl-A(select all) then break appart–then distribute to layers–and place each letter on the next frame kinda like this…
and you can do just that as a .swf then transport it to another .fla movie
hope that helps!!!

How can you make this effect loop?

you can do that in illustrator very easily in a sequence like the above or in a build…just type out whatever text you want, then go to type>create outlines then ungroup them (its kinda like break apart in flash) then select the layer they reside on and in the top right of the layers pallete click the button and go to RELEASE TO LAYERS you can pick build which will be like B BU BUI BUIL BUILD or sequence which is like the above. then just export as a .swf but make sure u set AI LAYERS to SWF FRAMES

To answer a couple of questions for the above comments, first use "
" for line break example - yourText = “hi There
good bye” the 2nd thing is this script allows for no function on frame 3, as the “i” has no meaning the script will work with just the gotoAndPlay(2); now the bad thing is you have no control on what to do after you text has finished typing, try putting a gotoAndPlay action in the stop()portion of frame 3, it wont work becase theres nothing to compare the condition to the lengh of the text, My simple workaround for this now is put the typing text as shown above in a movieclip with the 3 frames above, and then on the main timeline on the first frame that you have your typing text movie playing, use a timer script heres an example
var myTime:Number = 13;
function myTimer() {
mySetIntervalWin = setInterval(this, “myTimer”, myTime*1000);
PS this also answers the how to Loop question too B>) D-Wiz

Forgot to mention something about the timer script as the timer sits as coded in my previous post it will loop over and over.one of 2 ways to get out of it and that is use “clearInterval(your intervalName)” in the function part
so it should look like this
function myTimer() {
mySetInterval = setInterval(this, “myTimer”, myTime1000);
another method that works just as well is to use a delete function action Timer would look like this
function myTimer() {
delete myTimer;
mySetInterval = setInterval(this, “myTimer”, myTime
Hope this helps those of you who do-not want the endless looping action
(Moderators -If you want to append this post to my previos post feel free to B>)

what use it is when i has nothing to compare against ? great script, would be even better if u could actually put it to some use because it was finished of !

Thumbs down for this one !

IT didn’t freakin work for boobing sake! quad thumbs down

replace the ‘i’ with ‘loop’ in the third frame - works just fine.

(you should bind a textfield to the variable type)

Great one!

Like the command up just replace the i for loop and your good to go

Thanks, I recoded this as it’s very old school coding, and with some mistakes or not great stuff - better to do it with a function and clearInterval (or a class if you’re that way inclined! But I’m not a hardcore AS3 coder…)

Also strictly all variables should be typed, ‘text’ is a bad name for a textfield (reserved keyname) and textfieldname.text is now the standard AS/2 way of referring to a textfield and is far more flexible.

Try this on one frame, stops while it types then continues when finished:

var txt:String = “Why do dogs wag their tails?”;
var max:Number = length(txt);
var loop:Number = 1;
var interval:Number;

function typeLoop() {
question.text = substring(txt, 1, loop);
if (loop>max) {
} else {
interval = setInterval(typeLoop, 50);

This way you can change the speed of the text by changing the interval?

I was wondering if you could include a code for a text carriage return?