0 Replies Latest reply on Oct 5, 2007 3:07 AM by Dionisus

    Play when time come's up

    Dionisus
      I need your help with next script. I get a good digitaltimer script but I need to play a movieclip when 3 passes using the digitaltimer script.

      The digitaltimer script is:
      //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.stop_btn.onPress = function() {
      //stop the timer
      _root.timing = false;
      //reset the paused variable
      _root.paused = false;
      //reset the display textbox
      _root.timer_txt = "00:00:00";
      }
      _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);
      //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();
      }
      _root.timer_txt = hours+":"+minutes+":"+seconds;
      }
      };



      The script for playing movieclips is:
      clip.stop(); //clip is the name of the movieclip
      button.onRelease = function(){ //button is the name of the button, this script works when the button is released
      animation_mc.play();
      };


      I need to make the above script to work when 3 seconds passes or let's say when elapsedS=3
      THX