ActionScript 3.0 Lesson 12: Create a Real Clock in Flash Using Sytem Date and Time

Mon, Aug 10, 2009

ActionScript

This movie requires Flash Player 9

In this HD High Definition Flash tutorial after drawing a clock, from scratch, Avraham gives life, taking system date and time and through rotation method, makes it live!

This clock is now a web property performing revenue through ads.See the result!

I know it is fast, you can always stop the player, or mail questions…

Music: Pink Floyd Instrumental.

DOWNLOAD THIS TUTORIAL TO YOUR HARD DRIVE
DOWNLOAD THE SOURCE FLA FILE

CLICK HERE FOR A COMPLETE ACTIONSCRIPT 3.0 FLASH TIMER AND TIME CARTOON SMART TUTORIAL

HERE IS THE SOURCE CODE:

// Flash Actionscript 3.0 Clock
// by Avraham Saltoun.
// www.say-web.com
// FREE TO USE COPY and DISTRIBUTE!

// Let’s create the timer and the
// Date variable…

var myTimer:Timer = new Timer(1000);
var myDate:Date = new Date;

// Let’s create the time variables…

var mySeconds:int = new int;
var myMinutes:int = new int;
var myHours:int = new int;

myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER, UpdateHands);

//The Function below will happen every second,
// indefinitely

function UpdateHands (e:TimerEvent):void //returns no value!
{

// In action script by default
// a new date has the current
// timestamp assigned

myDate = new Date;

// Hour Variables

mySeconds = myDate.getSeconds();
myMinutes = myDate.getMinutes();
myHours = myDate.getHours();

// Check if it is afternoon

if (myHours < 12 ) {myHours = myHours - 12;}

//The names have to be IDENTICAL
// to the instances created!!

SecondHand.rotation = (mySeconds * 6);
MinuteHand.rotation = (myMinutes * 6);
HourHand.rotation = (myHours * 30) + (myMinutes*0.5);

//The additional rotation in order to small
//advance to the next hours....

trace (myDate);
}

Related Articles:

, , , , , , , , , , , , , , , , , ,

Comments are closed.

AVA Trading Forex
WIX create a FREE website.
Try ACT! 2010 Today
Accept Credit Cards
UseNeXT Fast Downloads
For Free Stuff Click Here

Get Paid for Filling Surveys


Go Daddy $7.49.com sale 125x125 Huddle Collaboration
oDesk Certified Action Script Programmer oDesk Certified Adobe Flash CS3 Designer oDesk Certified Adobe Photoshop 6.0 Designer

Compare Web Hosting Services and Prices

web hosting - Web Hosting guide to popular hosts.

Twitter Followers