Displaying Frame Numbers

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 go to frame 50 in the time line and right click (Mac: Ctrl click) and select: Insert Frame

    Click to enlarge
    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


  4. For Variable name type: displayNumber

    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 always go straight back to the Arrow tool . 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

Close    To Top
  • Prev Article-Flash:
  • Next Article-Flash:
  • Now: Tutorial for Web and Software Design > Flash > Basic > Flash Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction