A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11246 Flash Movies | 9 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Gurgen Tagvorian
» Title: Perpetuum Mobile
» Description: It's just a Perpetuum Mobile for you
» More by Gurgen Tagvorian


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

Featured Site

» Posted in the Flash Kit Links section
» Title: Atlantis Media Ltd
» Comments: Greg Rudman new media creative & website design - Atlantis Media Ltd


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

» How to convert FLV video to MP3 audio for Mac OS
» Join flv videos together with just a few clicks
» How to convert flv file to avi for mac os x
» How to Create Christmas Flash Greeting eCard without programming skills
» How to Create Real Estate Flash Photo Gallery Presentation
» How to burn DVD, VCD, SVCD
» How to convert FLV to ASF with FLV to ASF converter for Mac os X
» 5 ways to convert PowerPoint to video
» How to Make Vista Buttons
» Unknown Tag: Title10
Random Tutorial | Add Site

bbm.netBBM.net is designed to save you time and deliver the highest quality royalty-free music for your multimedia projects. Features include: over 450 Music Loop Packages from some of the best composers in the business, our music search engine to speed your selection process, alternate music versions & bonus sounds to use for rollovers or transitions, free technical support and free consulting.

Click here for details »

Product Designer
Aquent
US-WA-Redmond

Justtechjobs.com Post A Job | Post A Resume


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.12 Votes: 23
Hits: 1115
» 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
 
   
 

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers