First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Daniel Agostinelli

select the PM and AM using the shift key. press Ctrl+G to make them a group. double click on the new group, and you will be taken to a new editing screen for the AM and PM, which will now be separated. Select PM and press F8. name the symbol PM and set behavior to movie clip. do the same with the AM text, naming it AM. right click on AM, and select actions from the context menu. Copy in the following code:

onClipEvent (load) {
	time = new Date();
	ampm = time.getHours();
onClipEvent (enterFrame) {
	if (ampm>=12) {
		setProperty(this, _visible, false);

The first part says when the clip is loaded, we will assign two variables to values. A variable is a name that stores certain data, whether it be a number, a word or a time, whatever. In this case, we set time to new Date(). All this does is creates a new date/time slot with the name time. ampm is also a variable, but this time, it assigns only the hour of the day/night. We will be getting the hours from the date called time, thus we use time.getHours(). Now we can say that ampm is the same as the current hour (eg. if the time is 6:30am, ampm is the same as 6, or if it was 1:20pm, ampm is the same as 13, since flash is based on 24hr time.

In the next part, when the frame is entered, we create a loop, or conditional statement. All this says is if ampm (the current hour of the day) is greater than or equal to 12, the AM movie clip is invisible, so all we see is PM. The first part is easy to understand, we use 12 because if on a 24hr clock, the hour is greater than or equal to 12, it is PM, therefore, we do not need the AM clip. The next part under the code is what happens if the if statement is true. setProperty is just telling flash that we want to change a certain property of a certain movieclip. the parameters within the brackets, (&) are as follows:

this is the target path of the clip we want to alter. since we are applying the script directly to the clip, we can just write this. the next part is telling flash the property we want to change. in this case, it is the visibility of our clip. we use _visible to tell flash the property we want to change. the final part is the value we want to change the property to. Visibility can have one of two values, true or false. these are known as boolean values. they can also be represented as a 0 or 1. We want to make the clip invisible, so we say its visibility is false.

» Level Basic

Added: 2004-05-10
Rating: 6 Votes: 25
» Author
I am very new to flash, and have just learnt about actionscripting. This is my first tutorial, so please bear with any mistakes.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.