Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 204

Programming actionscript 3.0
Table of Contents

Advertisement

Example: Simple analog clock
A simple analog clock example illustrates two of the date and time concepts discussed in this
chapter:
Getting the current date and time and extracting values for the hours, minutes, and
seconds
Using a Timer to set the pace of an application
The SimpleClock application files can be found in the folder Samples/SimpleClock. The
application consists of the following files:
File
SimpleClockApp.mxml
SimpleClockApp.fla
com/example/programmingas3/
simpleclock/SimpleClock.as
com/example/programmingas3/
simpleclock/AnalogClockFace.as
Defining the SimpleClock class
The clock example is simple, but it's a good idea to organize even simple applications well so
you could easily expand them in the future. To that end, the SimpleClock application uses the
SimpleClock class to handle the startup and time-keeping tasks, and then uses another class
named AnalogClockFace to actually display the time.
Here is the code that defines and initializes the SimpleClock class:
public class SimpleClock extends UIComponent
{
/**
* The time display component.
*/
private var face:AnalogClockFace;
/**
* The Timer that acts like a heartbeat for the application.
*/
private var ticker:Timer;
204
Working with Dates and Times
Description
The main application file in MXML for Flex.
The main application file as a FLA file for the
Flash authoring tool.
The main application file.
Draws a round clock face and hour, minute, and
seconds hands based on the time.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents