5 Replies Latest reply on Oct 10, 2007 11:08 AM by kglad

    Two getTimer()??

    Funks_Da_Burn
      Is it possible to have multiple timers and pause only one of them?
        • 1. Re: Two getTimer()??
          kglad Adobe Community Professional & MVP
          that question doesn't make sense. the actual timer runs non-stop from the time your swf starts.

          getTimer() just retrieves that value (run time) at the time it's called. it doesn't stop the timer. so, you can call getTimer() as often as you like.
          • 2. Re: Two getTimer()??
            Funks_Da_Burn Level 1
            I actually have multiple timers on the stage as digital clocks, I just want to be able to pause one of them without pausing all of them. How can I do this?
            • 3. Re: Two getTimer()??
              kglad Adobe Community Professional & MVP
              you can do it using the code that's updating that clock.
              • 4. Re: Two getTimer()??
                Funks_Da_Burn Level 1
                I have this updating the clock

                //initial variables
                var timing:Boolean = false;
                var paused:Boolean = false;
                var remaining:Number;
                var elapsedTime:Number;
                var elapsedHours: Number;
                var elapsedM:Number;
                var elapsedS:Number;
                var elapsedH:Number;
                var startTime:Number;
                var remaining:Number;
                var hours:String;
                var minutes:String;
                var seconds:String;
                var hundredths:String;
                _root.play_btn.onPress = function() {
                if(!_root.timing) {
                if (_root.paused) {
                _root.startTime = getTimer() - _root.elapsedTime;
                } else {
                _root.startTime = getTimer();
                }
                //start timer
                _root.paused = false;
                _root.timing = true;
                }
                }
                _root.pause_btn.onPress = function() {
                //only pause if the timer is actually going
                if(_root.timing) {
                _root.timing = false;
                _root.paused = true;
                }
                }
                _root.onEnterFrame = function() {
                if (timing) {
                //calculate values
                elapsedTime = getTimer()-startTime;
                //hours
                elapsedHours = Math.floor(elapsedTime/3600000);
                remaining = elapsedTime-(elapsedHours*3600000);
                //minutes
                elapsedM = Math.floor(remaining/60000);
                remaining = remaining-(elapsedM*60000);
                //seconds
                elapsedS = Math.floor(remaining/1000);
                remaining = remaining-(elapsedS*1000);
                //hundredths
                elapsedH = Math.floor(remaining/10);
                //output to text box
                //add a 0 on the front of the numbers if the number is less than 10
                if (elapsedHours<10) {
                hours = "0"+elapsedHours.toString();
                } else {
                hours = elapsedHours.toString();
                }
                if (elapsedM<10) {
                minutes = "0"+elapsedM.toString();
                } else {
                minutes = elapsedM.toString();
                }
                if (elapsedS<10) {
                seconds = "0"+elapsedS.toString();
                } else {
                seconds = elapsedS.toString();
                }
                if (elapsedH<10) {
                hundredths = "0"+elapsedH.toString();
                } else {
                hundredths = elapsedH.toString();
                }
                _root.timer_txt = hours+":"+minutes+":"+seconds+":"+hundredths;
                _root.timer2_txt = hours+":"+minutes+":"+seconds+":"+hundredths;
                _root.timer3_txt = hours+":"+minutes+":"+seconds+":"+hundredths;
                _root.timer4_txt = hours+":"+minutes+":"+seconds+":"+hundredths;
                }
                };


                How do I tell it to only pause _root.timer3_txt?
                • 5. Re: Two getTimer()??
                  kglad Adobe Community Professional & MVP
                  put

                  _root.timer3_txt = hours+":"+minutes+":"+seconds+":"+hundredths;

                  inside a conditional statement.