Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-28-2009, 10:00 PM   #1
Alph649
Registered User
 
Join Date: Jan 2009
Posts: 3
Exclamation hitTest timer stop

well im making this maze for school and i was wondering if any of the more experienced coders out there could help me with it

here is the code for the timer

Code:
//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;
	}
}


if (_root.end.hitTest(_x, getBounds(_root).yMax, true)) {
            _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;
	}
};
the part that is italicised is the part i need help with

i want the timer to stop once the player hits the end of the game so if you could help me out...

PM me if you want the file or any more info

Thanks in Advance

Alph649 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generate random name for file, stop recording with timer, download file to pendrive. Magdalena ActionScript 2.0 4 12-03-2007 10:52 PM
Stop() not working emelep ActionScript 2.0 12 11-12-2007 12:44 PM
cant get timer to stop(); vee ActionScript 3.0 2 10-24-2007 09:59 PM
shared objects help vin23 Flash 8 General Questions 11 10-11-2007 06:05 AM
how do you stop a specific streaming mp3 w/o using stop all sounds ? marzstar ActionScript 2.0 1 01-17-2006 04:06 AM


All times are GMT. The time now is 06:30 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.