2 Replies - 4265 Views - Last Post: 21 January 2013 - 02:11 PM

#1 razzledee   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-January 13

Score to reduce with countdown timer

Posted 20 January 2013 - 04:21 PM

Hi all

Am stuck on how to get the score in my actionscript 2 quiz to reduce with time so as to make the quiz a bit more challenging. So for instance each question has 30 secs to answer and 30 points/question which reduces 1 point for every sec it takes to answer.
The as2 pulls questions from an xml file which has a default timer and score but I can also set the timer and score for each question as well depending on the difficulty.
I've tried everything to get the score to reduce with time but nothing seems to work and I have hunted high and low for answers.

So the xml that is applicable is is as follows...

<quiz DefaultTimeInSeconds="30" DefaultPoints="30" NumberOfQuestions="10" RandomQuestions="TRUE" DefaultIfCorrectAnswer="Answer is correct!" DefaultIfWrongAnswer="Wrong Answer! Correct answer is " TimeIsUp="Time is Up !">
	<question><![CDATA[<b>What is the capital of Serbia?</b>]]></question>
	<answers correctAnswer="Belgrade">
	<options explanationIfCorrect="That is correct! You won 7 points." explanationIfNotCorrect="Sorry, you are wrong. " timeInSeconds="10" points="7"></options>

And the as2 applicable to the timer and scoring...

function countdown() {
		countdown_txt.text = counter;
		if (counter == 0) {
			AnswerPopUp_mc.AnswerPopUp.DisplayResult.htmlText = "<b>"+ TimeIsUp +"</b>";

xmlData.onload = function () {
		// Default Time for solving
		DefaultTimeInSeconds = this.firstChild.attributes.DefaultTimeInSeconds;
			trace ("DefaultTime: " + DefaultTimeInSeconds);
		// Default Points
		DefaultPoints = this.firstChild.attributes.DefaultPoints;
			trace ("DefaultPoints: " + DefaultPoints);

if (NumberOfPoints[QuestionCounter]){ Points = NumberOfPoints[QuestionCounter] } else { Points = DefaultPoints }
		// start counter
		if (TimesForSolving[QuestionCounter]){ 
			countdown_time = TimesForSolving[QuestionCounter] 
		} else { 
			countdown_time = DefaultTimeInSeconds 
		} // now call the function
			counter = countdown_time;
			countdown_txt.text = countdown_time;
			intID = setInterval(countdown,1000);

Now I know that I should have the score = counter but am not exactly sure how to alter the code to do this.

Any help would be much appreciated.

Correction... it's not the score function but the points ie points for each question rather than the total score. So points = counter is what I need to change.


Is This A Good Question/Topic? 0
  • +

Replies To: Score to reduce with countdown timer

#2 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: Score to reduce with countdown timer

Posted 21 January 2013 - 05:45 AM

Why not have a remaining time variable that you then subtract from the final score?
Was This Post Helpful? 0
  • +
  • -

#3 razzledee   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-January 13

Re: Score to reduce with countdown timer

Posted 21 January 2013 - 02:11 PM

Thanks for the replay. Am not sure how I would implement that exactly. Could you be more specific please?

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1