How to insert date in a flash movie?

How to insert date in a flash movie ?

MMKt

pub40.ezboard.com/fkirupa…D=16.topic

if you have questions post.

Yes I do have a question :

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) {
&nbsp &nbsp &nbsp &nbsp hours = getHours();
&nbsp &nbsp &nbsp &nbsp minutes = getMinutes();
&nbsp &nbsp &nbsp &nbsp seconds = getSeconds();
&nbsp &nbsp &nbsp &nbsp 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

you need to create the date object.

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

///////////////////////////////\\\\\\\\\\\\\\\

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

/////////////////////////////\\\\\\\\\\\\\\

Just after my last post some minutes ago , I remembered have read last week your post concerning a digital clock you were working on;

Do you intend to finish it ?

Cheers
mmkt

no there isn’t a fucntion to get am/pm but one can easily be made using if statements.

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.

Here I am once again;

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
}

:slight_smile: I think I ´ve had enough work for you today.

Really thank you a lot.
MMKT

You put 2 } in a row where there should be only one. And put the ; at the end of your last line. It doesn’t make any difference, but it’s better that way…
pom 0]

as far as the 3:1:12 goes you can fix that by using another if statement.

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.

Hello
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

The code works great. I’ll give you a hint on the military time thing. An If statement will fix it. So what do you want to do? you want to make it so that when it is 13, it displays 1, up until when it says 24, it displays 12. Hope that helped. If not then let me know.