A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Analog Clock - won't chime...

  1. #1
    Junior Member
    Join Date
    Oct 2002
    Location
    San Diego
    Posts
    9

    Analog Clock - won't chime...

    Analog Clock - won't chime...

    I'm a relative newbie so you may have to talk real slow...

    Two problems here,

    1. I've been working on an analog clock tutorial and decided that I want it to chime on the hour - ya know, 3 chime for when the hour hand reaches the frame for three o'clock ect... But the hour hand movie clip has a stop action in the first frame that keeps the hands from rotating too fast, and that in turn (I think)prevents the chime sound from playing at the correct frames for each hour. I'm pretty sure this can be resolved using action script - but I've no idea how to do it.

    2. The first frame of the clock movie begins with all the hands at the 12 o'clock position - but I don't want the clock chiming 12 times every time it starts - only at midnite or noon.

    BTW this clock will be part of a screensaver that I'm working on - so size really isn't an issue.

    Here's a link to my clock file...

    http://www.members.cox.net/cuttlass/clocktest.zip

    Thanks,
    Dave

  2. #2
    Member
    Join Date
    May 2003
    Location
    Mn
    Posts
    72
    how does it know what time it is?

  3. #3
    Junior Member
    Join Date
    Oct 2002
    Location
    San Diego
    Posts
    9
    By using action script

    look at the actions for the clock movie clip

  4. #4
    Member
    Join Date
    May 2003
    Location
    Mn
    Posts
    72
    what part of the clock mc?

  5. #5
    Junior Member
    Join Date
    Oct 2002
    Location
    San Diego
    Posts
    9
    open th fla file
    there will be one frame on the timeline
    click on the bottom of the hands
    and then press F9
    that should bring up the actions window

  6. #6
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Your chime doesn't work because you are not using the same method as the movie!

    The onEnterFrame code sets the rotation of the hands rather than the frame number: only the first frame ever displays. In fact, these only need to be single frame movieclips.

    Therefore, it will never see your "chime" frames.

    To get the chime to work, you need to add more to the onEnterFrame movie function. For example, you could use something like:
    PHP Code:
    onClipEvent (enterFrame) {
        
    time = new Date();
        
    mil time.getMilliseconds();
        
    time.getSeconds();
        
    time.getMinutes();
        
    time.getHours();
        
    seconds._rotation s*6+(mil/(1000/6));
        
    minutes._rotation m*6+(s/10);
        
    hours._rotation h*30+(m/2);
            
    // NEW STUFF //
            
    if( != old_h ) { // Only do this check once per hour
                
    old_h h// reset old_h to use as a marker for the next hour
                
    if( == 12 || == ) {
                   
    do_12hour_chime_function();
                }
            }
            
    // END NEW STUFF // 


  7. #7
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    here is another approach -

  8. #8
    Junior Member
    Join Date
    Oct 2002
    Location
    San Diego
    Posts
    9
    Thanks! - Now I wish I understood what you did...

    The clock chimes correctly but the chime sound seems a little strange - it seems to be playing mutiple instances of the chime sound for each hour

    Also the output field keeps popping up when I preview the movie - What do I need to do to get rid of that?

    BTW - Nice site - I'll be using that link to www.actionscripts.org/tutorials.shtml

    Thanks for your patience...

  9. #9
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    I'm guessing that is for a_modified_dog!

  10. #10
    Junior Member
    Join Date
    Oct 2002
    Location
    San Diego
    Posts
    9
    Originally posted by AlsoGaiusCoffey
    I'm guessing that is for a_modified_dog!
    I apologize - yes it was

    AlsoGaiusCoffey,
    Thanks for the bit of code. I pasted it into the actions for the clock movie - but (as I'm sure you suspect) I'm still unclear on what to do next...

    Thanks for your patience..

  11. #11
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    here is an improved version, i have (//) commented the trace actions to prevent the output, simply uncomment if you need to test,
    testing can be done on this line -
    mm == 0 ? chimer = true : chimer=false;

    this says - if the angle of the minute hand is zero, an hour has passed, so set a boolean variable to true,

    this variable is checked, and if it turns to true, it runs the chimes function -
    chimer ? _parent.chimes(h) : null; // where h = hours

    we run a quick check with chimes(h) to remove 12 if PM, and feed the chimeMC clip with the correct amount -

    num > 12 ? num=num-12 : num;
    chimeMC.times = num;
    chimeMC.play();

    chimesMC loops, using variable - times, as a marker -
    amount++;
    amount >= times ?
    gotoAndStop(1) : gotoAndPlay(2);

    hth

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center