• home
  • forum
  • my
  • kt
  • download
  • Adobe Flash 8 Digital Clock using ActionScript

    Author: 2007-06-06 14:52:56 From:

    Time is money is a well-known saying. This tutorial explains how to make a Flash 8 Digital clock using ActionScript programming.
    Start Adobe Flash 8 and create a new document having 250x70 dimensions.


    Draw a text field on the stage using the Text tool from the Tools panel.
    In the Properties Inspector set the following for the text field:
    W:230; H:50; X:10; Y:10; also set the formatting, I choose Verdana, size 40, bold, color #990000, centered.
    Don¡¯t forget to select Dynamic Text and to give it the instance name clock_txt like in the picture below:

    clock1.jpg

    Insert a new layer and name it actions. Select the first frame of the actions layer, press F9 to open the Actions panel and put there the following code in (attention: ActionScript is case sensitive):

    this.onEnterFrame = function(){
    var time:Date = new Date();
    var hour = time.getHours();
    var minute = time.getMinutes();
    var second = time.getSeconds();
    var clock:String=new String();

    //format the way the time is displayed

    if(hour > 12){
    hour-=12;
    }
    if(hour < 10){
    hour = "0"+hour;
    }
    if(minute < 10){
    minute = "0"+minute;
    }
    if(second <10){
    second = "0"+second;
    }

    //now create the time

    clock = hour+":"+minute+":"+second;
    clock_txt.text=clock;
    }

    Now test the movie (CTRL+Enter) and see the result:

     

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      3D (20)
      Math Physics (14)
      3rd Party (5)
      Navigation (60)
      Actionscripting (26)
      Optimization (16)
      Animation (32)
      Projector (9)
      Audio (46)
      Special Effects (112)
      Backend (25)
      Text Effects (65)
      Drawing (18)
      Tips and Techniques (41)
      Dynamic Content (25)
      Tricks (6)
      Games (66)
      Utilities (19)
      Getting Started (71)
      Video (10)
      Interactivity (21)
      Web Design (22)

    New

    Hot