I am looking for a way, basically, to code an alarm clock for my computer. I want it to show the time, day of the week, month and day, and then based off that, I want it to show a message and play a sound once. I have four dynamic text boxes on the stage: time, display, day, date.
import flash.net.URLRequest;
import flash.media.Sound;
time.text = getTime();
function getTime(){
var time = new Date();
var hour = time.getHours();
var minute = time.getMinutes();
var temp = "" + ((hour > 12) ? hour - 12 : hour);
temp += ((minute < 10) ? ":0" : ":") + minute;
temp += (hour >= 12) ? " PM" : " AM";
return temp;
}
day.text = getToday();
function getToday(){
var weekday_array:Array = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var today = new Date();
var weekday:String = weekday_array[today.getDay()];
var temp = weekday + ",";
return temp;
}
date.text = getDayz();
function getDayz() {
var month_array:Array = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var calendar = new Date();
var number = calendar.getDate();
var month:String = month_array[calendar.getMonth()];
var temp = month + " ";
temp += number;
return temp;
}
display.text = getDisplay();
function getDisplay(){
time.text = getTime();
day.text = getToday();
date.text = getDayz();
}
Without the display.text block, everything works perfectly. When I try and fiddle with that last bit, either by doing a for or if function, it throws the whole thing off.
How do I make the display text box read what's in the other boxes, and then return a phrase based on those values? I took a basic class in actionscript like four years ago, so layman's terms would be highly appreciated.