13 March 2010 [Saturday] @ March 13, 2010 edit
How to insert date in a flash movie ?MMKt
if (hours >= 13){
ampm = "pm"
}else{
ampm = "am"
}
}
put that into your code, and then your final code should look something like this::
onClipEvent (enterFrame) {
now = new Date()
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
if (hours >= 13){
ampm = "pm"
}else{
ampm = "am"
}
}
time = hours+":"+minutes+":"+seconds+" "+ampm
}
that should work.
onClipEvent (enterFrame) {
now = new Date()
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
time = hours+":"+minutes+":"+seconds;
}
that code will work. The getHours() Minutes() etc are functions of the date object and therefore need that object to work. By saying now = new Date() you are create the needed date object.
anymore questions? post. Good luck
if you have questions post.
Testing the clock I realized there is a bug, letīs suppose exactly now is 3:01 on system clock; the digital clock displays : 3:1:00 and not 3:01:00 ;
Bellow the error message I got by testing am/pm code:
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 12: Statement must appear within onClipEvent handler
time = hours+":"+minutes+":"+seconds+" "+ampm
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 13: Unexpected '}' encountered
}
:) I think I īve had enough work for you today.
Really thank you a lot.
MMKT
The corrected code is as bellow:
onClipEvent (enterFrame) {
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
if (length(minutes) == 1){
minutes = "0"+minutes
}
seconds = now.getSeconds();
if (length(seconds) == 1){
seconds = "0"+seconds
}
time = hours+":"+minutes+":"+seconds;
}
Concerning the change from military to 12 hours I will have
to think a bit ; I am getting started and thatīs not as easy for me as it is for you.
Thank you.
MMkt
Do you intend to finish it ?
Cheers
mmkt
Great Guy it does work !
Is there a way to show off am /pm ?
I suppose "get"command picks up the date from system clock , device that informs ante/post meridiem as well so
that could be gotten likewise;
It that too much complicated ?
Thank you very much.
Regards
MMKT
/////////////////////////////\\\\\\\\\\\\\\
if (length(minutes) == 1){
minutes = "0"+minutes
}
if (length(seconds) == 1){
seconds = "0"+seconds
}
it is telling minutes to display a "0" in front of the digit if the length is 1. so that will display 01, 02, etc...just put that code into yours. And watch how many } you put at the bottom of the code. Its easy to get lost on how many of those you need.
Also, just so you know, Flash is going to display Military time. so 0-24 instead of 1-12, 1-12. This can be solved with another simple if statement. I'll let you try to figure that one out on your own. If you don't get it then post and I'll give ya a hand.
pom 0]
I have been at pub40.ezboard.com/fkirupa...D=16.topic as you suggested and got started by what it seemed the easiest one (let me first make an easier version to work before trying those others)
onClipEvent (enterFrame) {
        hours = getHours();
        minutes = getMinutes();
        seconds = getSeconds();
        time = hours+":"+minutes+":"+seconds;
}
I have created a movie clip , and inside this a dynamic text box called time.
I assigned your code to the movie clip.
But it does not work.
Could you please give me a help?
Cheers
MMKT
#If you have any other info about this subject , Please add it free.# |
| More »