A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


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

Featured FLA

» Author: Knife Butterfly
» Title: SkullCandle
» Description: Simple Skull with a candle burning on it.
» More by Knife Butterfly


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

Featured Site

» Posted in the Flash Kit Links section
» Title: Cesar Kobashikawa - online portfolio
» Comments: Cesar Kobashikawa's Portfolio


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

» FLV Converter for Mac
» After Effects Quality Effect using AS3
» FLV to 3GP: Convert video files from FLV (Flash Video) to 3GP for Mac
» create Christmas business flash presentation with hyperlinks
» Let Photos Show Your Happy Family this Christmas and Upload YouTube
» PowerPoint show to DVD slide show--- PPS to DVD
» How to burn FLV to DVD for Mac
» How to Create Christmas Flash Greeting Ecard with photos and music
» Getting Started In Flash
» 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 »

Web Production
Aquent
US-FL-Orlando

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 4
«prev 1 2 3 4

Apply this code to the PM clip:

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

This is the same as the above code, except the if condition. We have if ampm is less than or equal to 11 (since less than 11 is am on a 24hr clock, or not pm).

Now, if the time is 3:47pm, the am clip will be invisible, or if it is 7:29am, the pm clip is invisible. Note: one clip will be invisible only when the movie is played, not when it is being edited in flash.

There are many ways we could have done this, i just picked a way i like doing it.

Next we add the actual time. Just under the timeline you will see a grey bar. Press scene 1. We are now on our main (_root) timeline. Drag the interface clip from the library to the stage and center it. Right click on it, press actions from the context menu, and copy in this code:

onClipEvent (enterFrame) {
 time = new Date();
 twofourhours = time.getHours();
 timeminutes = time.getMinutes();
 timeseconds = time.getSeconds();
}
onClipEvent (enterFrame) {
 if (twofourhours>12) {
 timehours = twofourhours - 12;
 } else {
 timehours = twofourhours;
 }
}
 

CODE EXPLAINED:
When we enter the frame, we set a few variables. Like before, we create a new date slot called time. Remember when we named the dynamic text boxes; well now is when we will use those names. where it says twofourhours = getHours(), we are making twofourhours equal to the current time in 24hr form. We don't want this to be displayed because it is in 24hr format, so we give it a completely new name. Next, we take the minutes of the current time, and put the in our minutes box which we created earlier, we called it timeminutes. We do the same for the seconds.

The next part says when we enter the frame, we create a new if statement. If twofourhours (the current hour in 24hr time), is greater than 12, we convert it to 12hr format using the formula i created (Use your math skills). If it is greater than 12, we take 12 from it. simple maths.

The final, else statement is saying if the else statement is false, make timehours equal whatever hour flash has given to the twofourhours variable.

Thats it for this tutorial, you now have created a 12hr clock. Congratulations!


«prev 1 2 3 4

» 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

Whitepapers and eBooks

Symantec Whitepaper: Converging System and Data Protection for Complete Disaster Recovery
Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
  Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Symantec Whitepaper: Comprehensive Backup and Recovery of VMware Virtual Infrastructure
MORE WHITEPAPERS, EBOOKS, AND ARTICLES