• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Hour 12. Objects and Arrays > Task: Word Animation

Task: Word Animation

In this example, the entire Flash movie is one large text field that displays a message one word at a time. It gets the words from a sentence defined in ActionScript and changes to the next word every so many frames.

Start with a blank Flash movie.

Create a dynamic text field. Use a large font, such as 64 point. Place it in the middle of the screen and set the alignment of the text so that it is centered. Link this text field to the variable text.

Create a small movie clip by drawing a shape and then choosing Insert, Convert to Movie Clip. Name the instance of this movie clip Actions. Move the movie clip outside the visible area.

Place the following script on the movie clip. It starts off by using split to divide a sentence into an array of words. It then sets three other variables. The wordNum variable is which word is to be displayed next. The frameDelay variable is the number of frames that need to pass until the word changes. The frameCount variable keeps track of the frames as they go by.

onClipEvent(load) {
    // get the words
    wordList = ("Imagination is more important than knowledge").split(" ");

    // set up variables
    wordNum = 0;
    frameDelay = 6;
    frameCount = frameDelay; // prime for first word

The enterFrame handler checks to see whether frameCount equals frameDelay. If they are equal, it is time for another word. The new word is placed in the text field, which is at the root level. Then wordNum is increased to prepare for the next word. If there are no more words, then wordNum is set back to 0. The handler ends by increasing frameCount by 1, which it does every frame.

onClipEvent(enterFrame) {
    // time for new word
    if (frameCount == frameDelay) {
        _root.text = wordList[wordNum]; // display word
        wordNum++; // next word
        if (wordNum >= wordList.length) wordNum = 0;
        frameCount = 0;

Test your movie or look at 11wordserver.fla. You can color up the movie with some background elements. The example has a short message, but this type of movie could be an effective introduction to a larger presentation.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint