Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Quizz help

Guest
Aug 29, 2014 Aug 29, 2014

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.

TOPICS
ActionScript
577
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Aug 29, 2014 Aug 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

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 01, 2014 Sep 01, 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();

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Sep 01, 2014 Sep 01, 2014

Is there a question?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 01, 2014 Sep 01, 2014

yeah there is, three questions on one frame to answer so I'm trying to get a score for the three of them, I hate when code dosent work with this cause Ido rather show someone on person what's up Haha

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 01, 2014 Sep 01, 2014

level 3.jpg

This is the first screen as you can see i want the player too type the answers in the text box and then click the button to check the answers and get a score for them.

level2.jpg

this level i want the user to select from the combo list then do the same process as the last screen click the button getting answers and a score.

hope someone can help !!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Sep 02, 2014 Sep 02, 2014

basically you want to store your solution inside an object, and compare the indexes of the comboboxes with it

//say the Comboxes right solutions have the indexes 0,1,2

var combosolutions:Array = [0,1,2];

//when clicking the check Answers button you go through all the seelctedIndexes of your comboboxes and compare them to the combosolutions

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 04, 2014 Sep 04, 2014
LATEST

Cheers sorted

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines