Copy link to clipboard
Copied
I've tried looking for several resources but have not found any that cover the entire process.
I'm new to Animate and need to create a simple .swf file that displays the written date (Tuesday, Sept. 12) and the time in 12 hr format with AM/PM.
Would someone be able to walk me through the process?
Thank you!
Here is a working version of the one that is two frames, and that puts the date into a field:
Here's the FLA that made that:
http://colin.scienceninja.com/showdate.fla.zip
If you see a message that says that the file was made with a later version, don't worry about it. I'm often a little ahead of everyone else! It should work ok.
Copy link to clipboard
Copied
I don't think there is a simple one function way to do it, but you can get what you need in this sort of way (I tested it and it seems to work):
var days:Array = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var months:Array = ["Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."];
var ampm:String = "AM";
var d:Date = new Date();
var day:int = d.day;
var date:int = d.date;
var hour:int = d.hours;
var min:int = d.minutes;
var month:int = d.month;
if(hour>12){
hour = hour - 12;
ampm = "PM";
}
if(hour==0) hour = 12;
trace(days[day]+", " + months[month] + " " + date);
Copy link to clipboard
Copied
thanks for your quick response Colin.
Truly being a newbie to Animate, not very confident knowing how to get it started.
Should I do two different dynamic text fields and add the code on the properties?
If so, what should I name the text?
Copy link to clipboard
Copied
You could take things in stages. If you want this to update all the time the easiest way would be to have two frames, with the script I gave in a keyframe in frame 1, and this in a keyframe in frame 2:
gotoAndPlay(1);
That would then loop around forever, and as the date changes the text would update.
If you had one textfield you could have a line line this (instead of the trace command):
resultsText.text = days[day]+", " + months[month] + " " + date;
'resultsText' would be a dynamic textfield that was across frames 1 and 2, and in Properties you gave the textfield a name of resultsText.
It would be possible to have several fields for the different parts, but you would run into problems with getting the spacing correct.
See if you can get one field working.
Copy link to clipboard
Copied
thanks again for your help, it doesnt seem to be working for me.
for your initial post when using:
var days:Array = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var months:Array = ["Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."];
var ampm:String = "AM";
var d:Date = new Date();
var day:int = d.day;
var date:int = d.date;
var hour:int = d.hours;
var min:int = d.minutes;
var month:int = d.month;
if(hour>12){
hour = hour - 12;
ampm = "PM";
}
if(hour==0) hour = 12;
trace(days[day]+", " + months[month] + " " + date);
How was the document set up? Did you have to include any text? Where you working with only one frame?
Sorry for all of the questions, but getting a bit lost in trying to code this. Very much appreciate the help!
Copy link to clipboard
Copied
Here is a working version of the one that is two frames, and that puts the date into a field:
Here's the FLA that made that:
http://colin.scienceninja.com/showdate.fla.zip
If you see a message that says that the file was made with a later version, don't worry about it. I'm often a little ahead of everyone else! It should work ok.
Copy link to clipboard
Copied
That worked, thank you so much!
Copy link to clipboard
Copied
Just for completeness, there are better ways to do what you're doing. But please come back again, and with a new topic about whatever you need to know at the time. You could even have a topic about "here's how I'm doing the date, is there a better way?". For now though see how you get on on your own. Hope you have fun!