Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author: Nick Kouvaris
»  Title: Znax
»  Description: Znax is a board game. Click 4 tiles of the same color and form squares as big as you can. You will erase all the tiles inside the square and collect points. Get maximum score if you make a square with game edges.
»  More by: Nick Kouvaris


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 4941 Flash Sites | 1 New Flash Links
What's New | Top 100 Flash Site

Featured Site

»  Author Agence WOP Digital Agency
»  Title: Electricdrum
»  Description: French WOP Agency, 3D websites, Flash (Papervision, Away 3D), event or institutional projects. The agency operates on all digital projects: consulting, design, graphic design, development, online communication. The WOP agency follows you on the implementation of original, creative and optimized digital projects.


Random Links | Add your own Flash Related Links
Flash Tutorials 1481 Tutorials 7 New Tutorials Added!
What's New | Top100

» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» How To Make A Fathers Day Slideshow
» How To Make A Transparent Background of Your Flash File
» Create Flash Banner With Text Disco Light Effect Today we will introduce you a Text Disco Light eff
» Unknown Tag: Title10
Random Tutorial | Add Site


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Actionscripting/Basic

Categories 12 HOUR Digital Clock
Author: Daniel Agostinelli

 
Page 3
«prev 1 2 3 4 next»

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);
 }
}

CODE EXPLAINED:
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.

«prev 1 2 3 4 next»

» Level Basic

Added: : 2004-05-10
Rating: 6.03 Votes: 26
Hits: 1119
» 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.
Download (8 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments