Forum Topic: How do I stop a countdown AS 2.0?

(99 views • 3 replies)

This topic is 1 page long.

<< < > >>
None

Quebecboy

Reply To Post Reply & Quote

Posted at: 8/22/09 09:25 AM

Quebecboy NEUTRAL LEVEL 26

Sign-Up: 06/09/06

Posts: 637

I've made a countdown and all I want to do is to make it stop when I enter an other frame

I'm doing a quiz and the last question requires a timer... but when I click on the right answer, the change goes on the next frame and play the ''victory'' animation I've made.

...but what happen here, is that even if I click on the right answer, the event of my countdown when going to zero happens. After 10 seconds, my flash goes to my ''you lose'' animation, because I programmed him to do this.

here is the code:

stop();
start_time = getTimer();
countdown = 10000;
onEnterFrame = function () {
	elapsed_time = getTimer()-start_time;
	_root.count.text = time_to_string(elapsed_time);
	_root.count_down.text = time_to_string(_root.countdown-elapsed_time);
	if (elapsed_time >= countdown) {
    gotoAndStop(2455);
};
};
function time_to_string(time_to_convert) {
	elapsed_hours = Math.floor(time_to_convert/3600000);
	remaining = time_to_convert-(elapsed_hours*3600000);
	elapsed_minutes = Math.floor(remaining/60000);
	remaining = remaining-(elapsed_minutes*60000);
	elapsed_seconds = Math.floor(remaining/1000);
	remaining = remaining-(elapsed_seconds*1000);
	elapsed_fs = Math.floor(remaining/10);
	if (elapsed_hours<10) {
		hours = "0"+elapsed_hours.toString();
	} else {
		hours = elapsed_hours.toString();
	}
	if (elapsed_minutes<10) {
		minutes = "0"+elapsed_minutes.toString();
	} else {
		minutes = elapsed_minutes.toString();
	}
	if (elapsed_seconds<10) {
		seconds = "0"+elapsed_seconds.toString();
	} else {
		seconds = elapsed_seconds.toString();
	}
	if (elapsed_fs<10) {
		hundredths = "0"+elapsed_fs.toString();
	} else {
		hundredths = elapsed_fs.toString();
	}
	return hours+":"+minutes+":"+seconds+":"+hundredths;
}

I just when the countdown to stop when I enter the next frame

plz help me!

I love ya all!!

BBS Signature

None

Quebecboy

Reply To Post Reply & Quote

Posted at: 8/22/09 11:27 AM

Quebecboy NEUTRAL LEVEL 26

Sign-Up: 06/09/06

Posts: 637

plz it's for a school/friends project!

I love ya all!!

BBS Signature

None

Afro-Ninja

Reply To Post Reply & Quote

Posted at: 8/22/09 01:22 PM

Afro-Ninja EVIL LEVEL 37

Sign-Up: 03/02/02

Posts: 13,464

couldn't you just do

onEnterFrame=null;

?

BBS Signature

None

Quebecboy

Reply To Post Reply & Quote

Posted at: 8/23/09 10:30 AM

Quebecboy NEUTRAL LEVEL 26

Sign-Up: 06/09/06

Posts: 637

My god Thx!

Wow...so simple, but it worked!

I guess I'll just head for more tutorials I guess :/

I love ya all!!

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 09:08 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!