A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Can AnyOne Please explain how to create a clock like this?

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    10

    Can AnyOne Please explain how to create a clock like this?

    I m unable to attach the .fla file because it is a bigger size file. so Please refer the .swf file.
    Attached Files Attached Files

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Wow... i have never seen something like this before O.O

    I will be thinking how to achieve this...
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  3. #3
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    Don't do it the way they did

    Make a clip for each number - 0 through 9. Have a change number animation in each - in the zero clip, you have an animation of it changing from 9. So when the 9 is showing, show the 0 clip over it with the animation of the number changing from 9 to 0.

    Start a timer and check the user's clock a couple times a second and show the time.

    Yes, coding a clock is like a test question in a programming class. Like the example you gave, this can be a huge programming mess. Or if you use recursion, it can be a programming dream.
    Last edited by moot; 12-23-2013 at 10:45 PM.

  4. #4
    Junior Member
    Join Date
    Nov 2013
    Posts
    10
    I tried to make a blur clock. The 0 blurs to nothing and nothing turns to 1 and so on. I created a movieClip but how do i write code according to that? For (seconds%10) it is ok. but for other values it only changes while the current number changed to other number and stoped. My clock hours value continuously blurs not stopeed. I dont know how to write that code with a Timer. can you Pls explain the procedure??

  5. #5
    Junior Member
    Join Date
    Nov 2013
    Posts
    10
    I finally found a correct way.
    *******************code 1 Frame 1:initalising***************
    time1 = new Date();
    var hrs1 = time1.getHours()
    var mins1 = time1.getMinutes()
    var secs1 = time1.getSeconds()
    var hrsH1 = Math.floor(hrs1/10);
    var hrsL1 = hrs1%10;
    var minsH1 = Math.floor(mins1/10);
    var minsL1 = mins1%10;
    var secsH1 = Math.floor(secs1/10);
    var secsL1 = secs1%10;
    with (seclow)
    {
    gotoAndPlay("n" + String(secsL1));
    }
    with (sechigh)
    {
    gotoAndPlay("n" + String(secsH1));
    }
    with (minlow)
    {
    gotoAndPlay("n" + String(minsL1));
    }
    with (minhigh)
    {
    gotoAndPlay("n" + String(minsH1));
    }
    with (hourlow)
    {
    gotoAndPlay("n" + String(hrsL1));
    }
    with (hourhigh)
    {
    gotoAndPlay("n" + String(hrsH1));
    }
    ************************************************** *******
    ******************Code 2 Frame 3:Animation ***************************
    time = new Date();
    var hrs = time.getHours()
    var mins = time.getMinutes()
    var secs = time.getSeconds()
    var hrsH = Math.floor(hrs/10);
    var hrsL = hrs%10;
    var minsH = Math.floor(mins/10);
    var minsL = mins%10;
    var secsH = Math.floor(secs/10);
    var secsL = secs%10;
    with (seclow)
    {
    gotoAndPlay("n" + String(secsL));
    }
    if(secs%10==0){
    with (sechigh)
    {
    gotoAndPlay("n" + String(secsH));
    }}
    if(secs%60==0){
    with (minlow)
    {
    gotoAndPlay("n" + String(minsL));
    }}
    if(mins%10==0){
    with (minhigh)
    {
    gotoAndPlay("n" + String(minsH));
    }}
    if(mins==0){
    with (hourlow)
    {
    gotoAndPlay("n" + String(hrsL));
    }}
    if(hrs%10==0){
    with (hourhigh)
    {
    gotoAndPlay("n" + String(hrsH));
    }}
    **************************************************
    ******************code 3 Frame 5:continuation **************************
    now = new Date();
    nowsec = now.getSeconds()
    if(secs==nowsec){
    gotoAndPlay(4);
    }
    else { gotoAndPlay(3);}
    ******************************************

  6. #6
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    Yeah that's the code from the example you gave.

    Like I said, don't do it that way. It is bad programming in so many ways.

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