This is my first post on the entire board, so I would like to start off by saying it is nice meeting you all. I am 18 and new at this flash actionscript stuff. I have done Javascript and DHTML, so hopefully this will help me learn Actionscript a little easier. First problem I had with Actionscript is that no one ever seems to have a tutorial for making a Non-Military Time digial clock. I didn’t look too hard, but I couldn’t find one, so I decided to be on my own and make one. Well, I made one that worked, which is good.
I wrote a tutorial on it in case anyone wants to read it. It is the first tutorial I have ever written in my life, it doesn’t have example pictures yet, but I am working on it. There is an example of what I am talking about at the end of page.
Click Here Non-Military Time Tutorial to check out the tutorial. Hopefully it will come in handy. Remember I am new at this, so if there are any useless chunks of code or bad explanations, I am sorry.
Great job for writing your first tutorial! I added it to the bottom of my site (minus the milliseconds).
I played with the code a bit, to see if I could make a zero appear before the single digit hour (ex. 03:24:56 instead of 3 :24:56).
Any ideas? I can’t seem to get it to work. I tried using the code you used for the minutes and seconds, and adapt it to the hour part. Here is the original code:
function updateTime() {
myTime = new Date();
milliseconds = myTime.getMilliseconds();
seconds = myTime.getSeconds().toString();
while (seconds.length<2) {
seconds = “0”+seconds;
}
minutes = myTime.getMinutes().toString();
while (minutes.length<2) {
minutes = “0”+minutes;
}
hours = myTime.getHours().toString();
delete myTime;
for (clock; (hours>=13); hours-=12) {
}
for (clock; (hours==0); hours=12) {
}
}
fscommand(“allowscale”, false);
stop();
Here is what I’ve done to it to try and make the hours always be 2 digits:
function updateTime() {
myTime = new Date();
milliseconds = myTime.getMilliseconds();
seconds = myTime.getSeconds().toString();
while (seconds.length<2) {
seconds = “0”+seconds;
}
minutes = myTime.getMinutes().toString();
while (minutes.length<2) {
minutes = “0”+minutes;
}
hours = myTime.getHours().toString();
while (hours.length<2) {
hours = “0”+hours;
}
delete myTime;
for (clock; (hours>=13); hours-=12) {
}
for (clock; (hours==0); hours=12) {
}
}
fscommand(“allowscale”, false);
stop();
…any ideas?
Anyhow, great job on the tutorial bro. I enjoyed it.
Yeah, I have been having complications with adding the 0 there too. I have no clue why, but I am not that good with Actionscript yet. Hopefully I will find a fix for it later on.
Thanks for the compliment on the tutorial, and for using it on your site =)
Your site is pretty good. Keep up the good work. And congrats on winning the 2002-2003 Golden Web Award:)
Your site does run a little slow on my machine. May be my computer, but in case it isn’t, you might want to up your FPS rate.
The code that is given on the site is correct, however the code that is in the Final Source FLA is not right. Check it out because it shows how to put a ‘0’ in front of the numbers.
Oh hey, check that out a clock tutorial on Kirupa, I couldn’t find that, I musta skimmed over it or something. Does that clock have non-military time? That is what I always had trouble finding. That is why I created my tutorial.
Hmmm, is the flash movie playing on the page correct? It doesn’t show a 0 before the 1 (it is 1am)
no, it doesn’t have a 0 in front of the 1 for the hour, but it has zeros in front of the minutes and the seconds…use the same principle. Its just an if statement.
looks at the stars
My first post, back on the old forum, was about post incrementation, I still remember. I was VERY intimidated, but I quickly became David’s and Thor’s padawan