Categories
Featured jobs
» More ActionScript, Flash and Flex jobs.
» Advertise a job for free
Our network
Advertisement

 »  Home  »  Tutorials  »  Flash  »  Beginner  »  Scripted Typewriter Effect

Scripted Typewriter Effect

By Daniel Skovli | Published 09/9/2005 | Beginner | Rating:
Daniel Skovli
This user is yet to take control of their account and provide a biography. If you are the author of this article, please contact us via support AT actionscript DOT org. 

View all articles by Daniel Skovli
Page 1 of 1
Written by: Daniel Skovli with some additions by Jesse Stratford.
Time: 10 minutes
Difficulty Level: Beginner
Requirements: Flash 5 or above
Topics Covered: How to create a quick and easy typewriter effect, which supports limited formatting.
Assumed knowledge: Variables, String manipulation.

Download the Source file for this tutorial (zipped .fla, flash 5)

You have probably seen many different typewriter effects done in flash. So have I, but there was one I couldn't find - the pure actionscript typewriter. Therefore, I've written this tutorial. Follow these easy steps, and you'll have your own typewriter done in no-time:

Step 1 - Creating the layout and frames:

As you might have spotted from this screenshot - you need three frames to build your typewriter. I have put actions, buttons and text in separate layers, but that is just for structure. Make a dynamic text-box, and give it the variable name 'textbox'. This should go over all three frames.

Step 2 - creating the frame-actions:

Then, you are ready to create the actions to make the whole thing work:
o In Frame 1 we define the text we want to display. Use "\n" for a newline. Frame 1 has these actions

q = 1;
text = "this is where you put your text";
stop();

o Frame 2 checks if we've output all the characters yet, and if not it takes Q characters from the start of our string and shows them in the text field. Frame 2 has these actions:

if (q < text.length) {
        textbox = text.substring(0, q);
        q++
} else {
        textbox = text;
        gotoAndStop(1);
}

o Frame 3 is just a loop back frame. Frame 3 has these actions:

gotoAndPlay(2);

Step 3 - creating the button:

Make a button at frame 1, and place it on stage. This button should launch the typewriter, so it has to have a little piece of code attached to itself (right click the button, and chose actions).
o the button has these actions:

on (release) {
        play();
}

That's it, three easy steps. If you are wondering about any of the commands used, they are all very good explained in the actionscript dictionary. To open up the dictionary, press F1 while inside flash :o)
How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent

Verification:
Enter the security code shown below:
img


Add comment

Spread The Word / Bookmark this content

Clesto Digg it! Reddit Furl del.icio.us Spurl Yahoo!

Related Articles
Comments
  • Comment #1 (Posted by actionscript novice - tnenaga at yahoo.com)
    Rating
    you can also implement this feature using the following:

    this.createEmptyMovieClip("typewriter", depth)

    typewriter.onEnterFrame = function() {

    //call substring function here

    //once q is greater than length of text
    call:
    delete typewriter.onEnterFrame



    }
     
  • Comment #2 (Posted by Johnny - 8850i at hotmail.com)
    Rating
    Love the tutorial! Is there anyway I can use this with XML?
     
  • Comment #3 (Posted by Jake - jacob.landry at umit.maine.edu)
    Rating
    is there a way to get this to read from a .txt file? i have been looking and looking and i cannot figure it out. great tutorial though, helped me out a lot.
     
  • Comment #4 (Posted by Alvaro - chrno.thesinner at gmail.com)
    Rating
    Thanks it worked beatifully. BTW, if you want to use it with Flash Lite 1.1 just change
    textbox = text.substring(0,q)
    to
    textbox = substring(text,0,q)

    thanks again
     
Submit Comment



Search Entire Site
Add to Google
Advertisements
Article Options
Latest New Articles
Set up a simple IIS Server for Flash
by Peter McBride

Day 1 at FITC Toronto 2008
by Anthony Pace

Simple reflection effect with AS2
by Jean André Mas

ActionScript.org Meets Josh Tynjala (aka dr_zeus)
by ActionScript.org Staff

Rapidly Create Online Flash Movies to Help Users Market, Sell and Support Software and Hardware
by Sabrina F

mailing list
Enter your email address:
mailing list
Subscribe Unsubscribe
© 2000-2007 actionscript.org! All Rights Reserved.
Read our Privacy Statement and Terms of Use...
Our dedicated server is hosted and managed by WebScorpion Webhosting.