Welcome, Guest
  • Author Topic: AS 3 clock problem  (Read 518 times)

    nnnswordfish

    • Server what's that
    • *
    • Posts: 49
      • View Profile
      • Email
    AS 3 clock problem
    « on: 06/30/11, 13:41 »
    Hy guys.. i try to make digital clock in as 3 ... but no luck it not working... i uploaded all source files here an please can u cheek please were is error? and why it doesn't working? thanks
    Code: [Select]
    import flash.utils.Timer;
    import flash.events.TimerEvent;

    var time:Timer = new Timer(1000);
    var date:Date = new Date();
    var day:Number = date.day;
    var hour:* = date.hours;
    var minutes:* = date.minutes;
    var seconds:* = date.seconds;


    hideDaysAMPM(sun, tue, wed, thu, fri, sat, SunGlow, monGlow, tueGlow, wedGlow, thuGlow, friGlow, satGlow, am, pm, amGlow, pmGlow);
    function hideDaysAMPM(...hideDAP)

    {
       for (var i:int = 0; i<hideDAP.length; i++)
       {
          hideDAP[i].visible = false;
       }
    }

    switch (day)

    {
       case 0 :
       
       sun.visible = true;
       sunGlow.visible = true;
       break;
       
       case 1 :
       
       mon.visible = true;
       monGlow.visible = true;
       break;
       
       case 2 :
       
       tue.visible = true;
       tueGlow.visible = true;
       break;
       
       case 3 :
       
       wed.visible = true;
       wedGlow.visible = true;
       break;
       
       case 4 :
       
       thu.visible = true;
       thuGlow.visible = true;
       break;
       
       case 5 :
       
       fri.visible = true;
       friGlow.visible = true;
       break;
       
       case 6 :
       
       sat.visible = true;
       satGlow.visible = true;
       break;
       
    }


    time.addEventListener(TimerEvent.Timer, startTime);
    time.start();


    function startTime(e:TimerEvent):void{
       date = new Date();
       hour = date.hours;
       minutes = date.minutes;
       seconds = date.seconds;
       
       
       if(Number(hour)> 12){      {
          hour -= 12;
          pm.visible = true;
          pmGlow.visible = true;
          }
       
         else{
             am.visible = true;
             amGlow.visible = true;
          }
          if(String(hour).length < 2){
             hour = "0" + hour;
          }
           if(String(minutes).length < 2){
             minutes = "0" + minutes;
          }
           if(String(seconds).length < 2){
             seconds = "0" + seconds;
          }
         
          clockTxt.text = hour + ":" + minutes + ":" + seconds;
          clockTxtGlow.text = hour + ":" + minutes + ":" + seconds;
    }

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: AS 3 clock problem
    « Reply #1 on: 06/30/11, 15:41 »
    Can you spot what the problem is?

    Jorge