Typewriter effect in flash can be useful in creating banners or presentations. This tutorial explaines how to create a flash type writer effect using ActionScript.

 Steps to follow:

1. Open Flash 8, create a new document and save it as typeeffect.fla. Go to the Properties panel or choose Modify >> Document (Ctrl+J) and set the dimensions of your flash document to 350×200 pixels.

2. Insert two layers so that the total number of layers is three. Rename them from top to bottom as it follows: actions, text, background (like in the image below).

Layers in Flash

3. In the first frame of the background layer insert a picture with dimensions 350×200. The one I used is from pdphoto.org. Choose File >> Import>> Import to Stage and select the picture from your computer. Align the picture to center of the stage both horizontal and vertical from the Align panel (Window >> Align or Ctrl+K if it is not opened).

Flash Align panel

4. Click the Text Tool (T) to select it. Go to the Properties panel and set Dynamic Text as Text Type, font Arial, size 25, color white #FFFFFF, bold, align center. Now go to the first frame of the text layer and draw a text field there. Select it and go back to the Properties panel and set W:3 30.0, H: 180.0, give it an instance name of display_txt and then align it to center horizontal and vertical using the Align panel.

text field properties in Flash     display_txt

5. While the display_txt go to the Filters panel (second tab of the Properties panel). Click the plus sign Add new Filter in Flash to add a filter and choose Drop Shadow from the list that appears. Set the properties as it follows: Blur X:5, Blur Y:5, Angle: 45, Color black #000000.

Drop Shadow filter in Flash 8

6. Now go to the first frame of the actions layer and open the Actions panel (F9). Put the following ActionScript code in:

var phrase_string:String="What I want to say : \n I love Fish";
var n:Number= phrase_string.length;
var i:Number=0;
this.onEnterFrame=function(){
 if (i<n){
  display_txt.text+=phrase_string.substr(i,1);
  i+=1;
 }
}

Now let’s see what the code does. I use phrase_string variable to hold I want to display. You may put here what text do tou want. The \n is a line break, so finnaly I would have three lines.

The n variable is for holding the lenght of phrase_string. The i variavle is a contor to cover all the chars from phrase_string.

Then I use onEnterFrame event for doing some action: if i is less than n I will add to display_txt.text the char from i position in phrase_string.

7. That it’s all. Test tour movie (Ctrl+Enter) and ask me if you have any doubts.

23 Responses to “Type writer effect using ActionScript”
  1. AGeek says:

    nice tutorial. thanks a lot

  2. DANI says:

    very coooooooooool;keep it up!

  3. Teonnyn says:

    I am trying to use this typewriter effect, however all it does is type the first letter of my phrase then repeat.

  4. Teonnyn says:

    Whoops. My bad, I forgot to add stop();

  5. music says:

    very interesting.
    i’m adding in RSS Reader

  6. abishek says:

    it is wonderful..

    but i have two queries

    1.can we increase the typing speed and
    2. can we place the action script frame at any place in the timeline in that layer ( or should it be in first frame only..)

    thank you.

  7. Phelix says:

    thanks so much for this tutorial. but i advice anyone who would use this to use a font size of maybe 8 in other see all the test.

  8. music says:

    What do you mean ?

  9. ravendraxds says:

    really this is a good tutrial I am enjoying thisone

  10. Bloggerita says:

    To abishek:

    1. Yes you can and the simplest way to do it is modifying the frame rate of your lash document.
    2. This movie has only fisrt frame. I don’t know to answer your question because it depends of your movie clip.

  11. lampie says:

    a very good tut! ^_________^
    thanx so much.

  12. arezu says:

    hello..this tutorial really mean to me.
    but I have other question.
    How if I want to create other text,that mean in other lines. Do I have to out the actionscript in the 2nd frame of the action layer?? Please help me

  13. srinivas says:

    i don’t get that action, please give more deatail to that typeeffect text and i am using flash 7, this script work in flash 7 or not

  14. john says:

    how can i loop it?

  15. Anjali says:

    Nice One
    Only doubt about how to increase and decrease speed

  16. frurryjon says:

    Snx for you job!
    It has very much helped me!

  17. Nihal says:

    Thanks for the tutorial !
    Its great and helped me a lot. To get the multiline effect just choose the multiline while slecting the text properties.

  18. bowman32100 says:

    After working all day I visited this website and guess what? I sound this source and I don’t feel tired any more! It’s the best entertaining source!

  19. kumar says:

    thanks so much for this tutorial. it’s very very simple

  20. raltMangags says:

    wow ))
    its very interesting point of view.
    Nice post.
    realy good post

    thx :-)

  21. irka says:

    yeah, i have the same question as john. how can i loop it? anyway - great tutorial, many thanks :)

  22. Kurt Van Schaeybroeck says:

    Actually,

    the += method to add text is already deprecated, it’s better to use the textfield.appendText() method.

  23. Codgiplip says:

    Hello
    Nice site!

    Bye

Leave a Reply