8 Replies Latest reply on Mar 30, 2009 5:35 AM by Newsgroup_User

    System clock

    Level 7
      I need to make a clock with the system time. I know that using this command:
      put the time
      I can get the system time. But how to get every second and show a clock.

      many thanks


        • 1. Re: System clock
          Wolfgang Herold Level 2
          Hi Arielle,

          try

          the long time.
          not documented yet, but works.

          there is also a "Analog Clock" in the Behaviourlibriry - Controls.

          Wolfgang
          • 2. Re: System clock
            Level 7
            Thank you.
            I need the system clock in format like : 13:10:12



            "wherold" <webforuankmsuser@macromedia.com> escribió en el mensaje
            news:gqlnis$bi1$1@forums.macromedia.com...
            > Hi Arielle,
            >
            > try
            >
            > the long time.
            > not documented yet, but works.
            >
            > there is also a "Analog Clock" in the Behaviourlibriry - Controls.
            >
            > Wolfgang


            • 3. Re: System clock
              Level 7
              You can use the long time which is going to be formatted the way that
              the operating system is set up to display time. If you need it in a
              specific format, then you would have to parse it yourself (which is
              tricky since different people can have it formatted differently).

              Or you can use BuddyAPI which has a command called baSystemTime() which
              will let you format it arbitrarily in any way you'd like.
              • 4. Re: System clock
                Level 7
                Or you could use a JavaScript Date() object and some of its methods to
                format the time as desired.
                • 5. Re: System clock
                  fazstp
                  on WhatsTheTime
                  v_time = ( the systemDate ).seconds
                  v_time_string = EMPTY

                  v_hour = v_time / 3600

                  if ( v_hour < 10 ) then
                  put "0" after v_time_string
                  end if

                  put v_hour & ":" after v_time_string

                  v_time = v_time MOD 3600

                  v_minutes = v_time / 60

                  if ( v_minutes < 10 ) then
                  put "0" after v_time_string
                  end if

                  put v_minutes & ":" after v_time_string

                  v_time = v_time MOD 60

                  if ( v_time < 10 ) then
                  put "0" after v_time_string
                  end if

                  put v_time after v_time_string

                  return v_time_string

                  end WhatsTheTime
                  • 6. Re: System clock
                    Level 7
                    Thank you.
                    I don't care to much the format of time but how to show it every second.

                    "fazstp" <webforumsuser@macromedia.com> escribió en el mensaje
                    news:gqm2s0$o9p$1@forums.macromedia.com...
                    > on WhatsTheTime
                    > v_time = ( the systemDate ).seconds
                    > v_time_string = EMPTY
                    >
                    > v_hour = v_time / 3600
                    >
                    > if ( v_hour < 10 ) then
                    > put "0" after v_time_string
                    > end if
                    >
                    > put v_hour & ":" after v_time_string
                    >
                    > v_time = v_time MOD 3600
                    >
                    > v_minutes = v_time / 60
                    >
                    > if ( v_minutes < 10 ) then
                    > put "0" after v_time_string
                    > end if
                    >
                    > put v_minutes & ":" after v_time_string
                    >
                    > v_time = v_time MOD 60
                    >
                    > if ( v_time < 10 ) then
                    > put "0" after v_time_string
                    > end if
                    >
                    > put v_time after v_time_string
                    >
                    > return v_time_string
                    >
                    > end WhatsTheTime
                    >


                    • 7. Re: System clock
                      Level 7
                      > I don't care to much the format of time but how to show it every second.

                      If that's a question you're asking (about how to perform an action once
                      every second) then I'd suggest either using a #timeout object (with a
                      period of 1 second) or using a regular event (like
                      prepare/enter/exit/stepFrame) and monitoring _system.milliseconds to
                      determine whether 1000 have passed since the last time you updated your
                      displayed clock
                      • 8. Re: System clock
                        Level 7
                        Arielle wrote:
                        > I need to make a clock with the system time. I know that using this
                        > command: put the time
                        > I can get the system time. But how to get every second and show a
                        > clock.

                        If you attach this behaviour to a text member it will do that:

                        ----------------------------------------------
                        property spriteNum, myMember, lastTime

                        on enterFrame
                        thisTime=framesToHMS((the systemDate).seconds, 1, false,false)
                        -- remove trailing ".00"
                        thisTime=thisTime.char[1..offset(".",thisTime)-1]
                        -- only update if the time has actually changed
                        if thisTime<>lastTime then
                        lastTime=thisTime
                        myMember.text=thisTime
                        end if
                        end enterFrame

                        on beginSprite
                        myMember=sprite(spriteNum).member
                        end beginSprite

                        ----------------------------------------------

                        Andrew