Her

Home Flash & Swish Flash Tutorials Displaying Frame Numbers

Displaying Frame Numbers

Author: Phil Author's URL: www.webwasp.co.uk More by this author

The aim of the tutorial is to learn how to use actionscript to display the frame number.

Example of frame number being displayed.

Step one: Document setup

The number of frames per second is controlled by the default setup. You cannot have one part of a movie playing at 12 frames pre second and another playing at 8 frames per second. To change the default setup:

  1. Go to: Modify > Document
  2. You will see: Frame rate: 12 fps
    or something similar. The movie above is set at: 12 fps (frames per second)
  3. If you wish change the setting. This will slow down or speed up the play rate of your movie.
  4. Click: OK

    Note: Remember that you can change the frame rate at any time.
  5. With the Arrow Tool image 1 go to frame 50 in the time line and right click (Mac: Ctrl click) and select: Insert Frame

    Displaying Frame Numbers
    The time line with 50 frames (Click to enlarge)

Step two: Display text box

You need a text box on stage so that the number can be displayed.

  1. With the text tool selected, drag on stage to create an empty text box.
  2. If the Property panel is closed, open it: Window > Properties
  3. In the drop down menu select: Dynamic Text

    image 2
  4. For Variable name type: displayNumber

    image 3
    Do not get confused with instance name. If you type the name in the wrong box it will not work!

  5. In the Property panel select a Font and Font colour.

    Tip: As soon as you have finished with the Text tool image 4 always go straight back to the Arrow tool image 1. This stops you typing on stage by mistake.

Step three: ActionScript

  1. Right click on frame one and select: Actions
  2. The Actions panel go to the View Options button and select: Expert Mode
  3. Type the following code:

    onEnterFrame=function(){
        _root.displayNumber=_root._currentframe;
    }

  4. Test your movie. To do this go to: Control > Test Movie

    Your movie should display the current frame number.
Note: If you do not want to display the frame number of the main time line but the frame number of a movie clip, give the movie clip an instance name and change the second line of script to:
_root.displayNumber=_root.myInstanceName._currentframe;

Example of frame number being taken from Movie Clip