Flash Timer…

Okay, I didn’t release those new lessons earlier today because:

Choose one…

1. Napping is way more enticing than actually working

2. Problems uploading the lesson’s zip files.

If you ignored the “Choose one” and chose both, you’re right.  But really, I can’t upload anything major at the moment, so I’m stuck here blogging instead of selling new shiz.

Sigh. So I’m stuck staring blankly at the clock which reminds me I need to do something I meant to do days ago which was get back to an emailer who inquired about making a Flash movie that would detect the current time and display giant messages based on that. This gentleman is trying to create something that will always be running fullscreen on his computer, so while he’s at work, his mother with Alzheimers has some idea of what to do during the day. Pretty creative use of Flash I thought.  So the source files for this are linked up below (or here) but if you want a few lines of Actionscript 3 regarding this, here goes…

var now:Date; // says Date, but we’ll break it down to hours momentarily

addEventListener(Event.ENTER_FRAME,enterFrameHandler); // constantly running function

function enterFrameHandler(event:Event):void {
now = new Date(); //gets the most current date
var hours:int; // var for the hours
hours = Number( now.getHours() ); // and now we actually find out the hour from the now (Date ) var

if ( hours == 2 ){
trace ( “Mom, its time for breakfast” );
}
}

If you paste that into your Actions panel (and if its 2 am or 2 pm) it should inundate you with trace statements telling you the message above. The finished version includes code for minutes and seconds, combines everything into a nice running clock (which you could customize the fonts for),  detects AM or PM, and uses a text box instead of trace statement to check for various times during the day.

Enjoy.

Click to Download "Message Timer" example .fla

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s