SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict Scud's Avatar
    Join Date
    Jan 2002
    Location
    Los Angeles
    Posts
    222
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Flash: Randomized Quiz

    I'm re-doing one of my older Authorware projects in Flash for my portfolio. What I need is to make a quiz that will pull xnumber of questions from a pool of xnumber questions at random (with no repeating the same question).

    I've browsed the net and searched multiple forums and not found a tutorial or .fla to look at. I've checked Flashkit and a few other small personal sites. Anyone happen to have a link on hand or able to walk me through the basics of what I need to do?

    Thanks!

  2. #2
    SitePoint Member
    Join Date
    Dec 2001
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Shouldn't be too hard.
    Just enter the questions in an array like this:

    questions = new Array ("what is love?", "what is the meaning of life?", "What is your favourite color?");

    Then when you want to display them use a textfield (named for example 'qdisp'). Use a second array (beenasked)
    to keep track of what questions have been asked.

    function newQuestion(){
    randomnumber=random(questions.legnth-1);
    while( beenasked[randomnumber]==1 ){
    randomnumber=random(questions.legnth-1);
    }

    beenasked[randomnumber]=1;
    qdisp=questions(randomnumber);
    }


    You'll have to throw up a little if-statement just to check that all questions haven't been asked (which would create an open loop crashing the application).

    Hope that helps.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •