A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11337 Flash Movies | 1 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Bugra Ozden
» Title: Skatalog v9 - product catalog
» Description: Create your product catalog easly and publish on your website or Create your image gallery, documents list, portfolio. Fully XML Driven
» More by Bugra Ozden


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

Featured Site

» Posted in the Flash Kit Links section
» Title: Creative DW Image Show PRO
» Description: Creative DW Image Show PRO is a Dreamweaver extension which enables the user to create multimedia presentations. It combines the features of the popular Creative DW Image Show with the ability to add professional text effects to slides (similar to After Effects). The product is very customizable: the user can choose the duration of the transition effects, the slide motion start and end position, zoom and panning type for both images and texts.


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

» Make a Flash Slide Show Screen Saver
» Simple flash making tutorial for thanksgiving
» Create flash banner for website
» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» Unknown Tag: Title10
Random Tutorial | Add Site

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume


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

Search Tutorials


Tutorials Tutorials » Actionscripting

Categories smooth-moving analog clock
Author: luco | Website: http://www.luco.com.br |

 
Page 3
«prev 1 2 3 4 next»

[code]

all right! we have the board, we have the pieces. it's definitely time to make them... move. (thunder sound fill) put an instance of the clock on the stage and name it something complex and unreasonably odd like "clock". just for fun. this clock's gotta be a movieclip for this to work, you know. then select the clock and add the following code to it (you should see something like "actions - Movie Clip" on the Actions Pannel):
onClipEvent (enterFrame) {
    // gets the time information and stores in a variable called "now"
    now = new Date();
    // assigns values individually
    h = now.getHours();
    m = now.getMinutes();
    s = now.getSeconds();
    // angle adjust relative to the hours
    setProperty(_root.clock.hrs, _rotation, (h+1)*30);
    // angle adjust relative to the minutes
    setProperty(_root.clock.min, _rotation, m*6);
    // angle adjust relative to the seconds
    setProperty(_root.clock.sec, _rotation, s*6);
}
now for some explanation. let's brake it! uhm, just drop the baseball bat, son.
    onClipEvent (enterFrame) {
this opens up an event to be executed by the clock movieclip. at every second, this script will repeat, creating a nice tick-clock effect!
    now = new Date();
this gets the current time and stores it in a variable called "now" all the time. cus now IS all the time. and the clock hands use this variable to display time correctly all the time! neat, huh?
    h = now.getHours();
    m = now.getMinutes();
    s = now.getSeconds();
now we separate hours from minutes and seconds. very useful ahead.
    setProperty(_root.clock.hrs, _rotation, (h+1)*30);
here we set the angle of the hours hand using the hour provided by New Date() and multiplying it by 30. why 30? divide 360, wich is the number of degrees in a circle (any circle, even if you didn't draw it) by 12, the number of hours in a clock (any clock, even for the Gestalt freaks). and (h+1) will assure you'll never get a zero (cus midnight is displayed as 00:00.)
    setProperty(_root.clock.min, _rotation, m*6);
    setProperty(_root.clock.sec, _rotation, s*6);
these lines have the same function, operating on minutes and seconds. because you get as many minutes in an hour as you get seconds in a minute, the numbers are strictly the same, and they each jump on increments of 6 degrees.

«prev 1 2 3 4 next»

» Level Intermediate

Added: : 2003-12-28
Rating: 5.85 Votes: 21
Hits: 1226
» Author
Brazillian advertiser-webdesigner hybrid. likz art, heavy, grooved electro-music + Brazillian rythms. plays capoeira. enjoys comedies, but when watches drama cries like a baby. that's it!
» Download
Download the files used in this tutorial.
Download (10 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.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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