Groups | Blog | Home
all groups > flash actionscript > march 2006 >

flash actionscript : How do display the month, date, and time in .swf?


digitalnoob
3/19/2006 9:50:30 PM
Hi all,

I looked at
http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=288&thre
adid=877312&highlight_key=y&keyword1=display%20date

--but was unable to get the examples to work as I would get clipevent errors.
Also some of the examples said to just put the script on the actionscript
layer. In that case, how do you control where the date appears?

Anyway, I need to show the Month + date + time i.e. "March 19 4:56"

I don't know if i do this in a dynamic text field, movie clip, etc.

Would anyone be so kind as to give the exact actionscript that needs to be
used and where the script goes?

Thanks very much!
kglad
3/19/2006 9:59:24 PM
you need to decide how that info is to be displayed. usually, it would be
displayed in a dynamic textfield that you create with actionscript or in the
authoring environment. once you create your textfield you can assign its text
property to contain the display you want.

the location of the code is not important except to know the path from the
variables used in the code to the textfield and it's important to know if that
display is to be updated periodically (and if so, how often) or just checked
once and displayed at a particular time in your project.
digitalnoob
3/19/2006 10:07:57 PM
Hi kglad!

Thanks for your help the other day, I have been trying to rework the a.s. as I
need to change a few things. It has been a long and painful process for my
brain but I am slowly, very, very slowly, starting to see the 'grammar' of a.s.

Thanks for replying to this post.

In response:

I just need to show the time, month, and date in the area I want to show when
my student prints out the test results (of the .fla you saw last week). The
time doesn't need to refresh; the student would print it out right away before
closing the .swf or pressing the Enter key to restart it.

As for whether or not it is a dynamic textfield or some other vehicle, it
doesn't matter to me; I just need to use the simplest vehicle and its
accompanying actionscript.

Thanks again!
kglad
3/19/2006 10:16:56 PM
if you can accept the date/time from the users computer you can use the flash
date object: create a dynamic textfield in the authoring environment on your
results frame and give the textfield an instance name, say tf.

attached to your results frame you can then use:

currentDate=new Date();
monthA=["January","February", etc];
if(currentDate.getMinutes()<10){
minutes="0"+currentDate.getMinutes();
} else {
minutes=currentDate.getMinutes();
}
tf.text=monthA[currentDate.getMonth()]+" "+currentDate.getDate()+"
"+currentDate.getHours()+":"+minutes;
digitalnoob
3/19/2006 11:14:26 PM
Hi,

Thanks for your reply.

I did as you directed. However, when I test the movie, instead of the date, I get "undefined 19 16:12"

any reason for that?

AddThis Social Bookmark Button