Skip to main content
August 29, 2014
Question

Quizz help

  • August 29, 2014
  • 1 reply
  • 638 views

Hi im pretty new to action script and have been playing around with bits of code for a little project i am doing at university

i basically have a AS3 maths game with three different levels on it with questions on it.

The first level i used radio buttons these used to answer the 3 questions, once these are clicked it is linked to a score if its correct you get 10 points.

Heres my problem.... level 2 i have 3 combo boxes to enter the answers to the questions on the stage but i want to make it so when all the questions have been answered you click a button to check if you are right and get a score out of 30.

level 3 i have the input text field where you type the answers in and want to do the same where you enter the answers click a button to see if you are right and get a score.

but all the code i am typing in is not working PLEASE HELP as its driving me crazy  haha.

This topic has been closed for replies.

1 reply

Inspiring
August 29, 2014

"but all the code i am typing in is not working"

google: quiz as3 tutorial and work through one of the results

If you have specifically a problem of tracking the amount of questions that have already been answered,

you must create some variable that functions as a counter thta increments a certain value.

//at the beginning of your quiz

var counter:int = 0;

var rightAnswers:int = 0;

const QUESTIONS:int = 30;

//whenever a user clicks on one of your radio buttons

counter ++;

if(checkAnswer ()){

  rightAnswers++;

}

if(counter == QUESTIONS){

   showScore();

}

function showScore():void{

   trace("you have answered " + rightAnswers+"  of  " + QUESTIONS);

}

function checkAnswer():Boolean{

   //depending on how you store values in your application you have to programm a routine

   // that either returns true or false

}

September 1, 2014

I have the radio buttons questions working so heres the code i tried for the comboboxes and the text fie

//text box

import flash.text

import flash.events.MouseEvent;

// starting out with a  score of 0

var myscore = 0;  score.text = myscore+"";

// creating a new instance of  the textGroup Class

var mygroup1:text = new text("text1");

answer1_txt.group = answer3_txt.group = answer3_txt.group =mygroup1;

answers.addEventListener(MouseEvent.CLICK, quizHandler1)

function  quizHandler1(event:MouseEvent):void{

if(mygroup1.selection.label=="45"){myscore+=10;  nextFrame();

}

}

//combobox

import fl.controls.ComboBox;

import flash.events.MouseEvent;

// starting out with a  score of 0

var myscore = 0;  score.text = myscore+"";

// creating a new instance of  the ComboBoxGroup Class

var mygroup1:ComboBox = new ComboBox("Combo1");

answers.addEventListener(MouseEvent.CLICK, quizHandler1)

function  quizHandler1(event:MouseEvent):void{

if(mygroup1.selection.label=="45"){myscore+=10;  nextFrame();

}

}

Inspiring
September 1, 2014

Is there a question?