Saturday, October 23, 2010

PE5 Flash ActionScript 3

My next tutorial from Lynda.com with ActionScript 3 dealt with Timers.  In the past, I would usually use something called “Set Interval”, or in its correct method – setInterval - for functions dealing with time.  I found Timers to be extremely useful and way more efficient than setInterval.

The tutorial used the Timer to make the snow boarder jump in the air every 5 seconds.  While this was fun, it felt too easy.  I decided to take the new information on Timers and proceeded to create a digital clock.    

I explored Flash help and other tutorials online and found the right syntax needed to start a clock.  First I had to set today’s date.  I have done this before in ActionScript 2, but of course it was different in ActionScript 3. 

 var dateToday:Date = new Date();

The Date class was created and new Date(); pulls in the information from the system date on the computer.

Now I had to create the hours, minutes and seconds.  Again, this was different that ActionScript 2.

var clockHour:Number = dateToday.hours;
var clockMin:Number = dateToday.minutes;
var clockSec:Number = dateToday.seconds;

Finally, I brought it all together by giving the dynamic text instance names, embedding the fonts and by throwing everything in a movie clip in order to finally give it a nice blue glow.



Here is the final digital clock. 



My next tutorial is on Classes.  I have never created my own class before so this will be uncharted territory. 

0 comments:

Post a Comment