A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: A questions list ...

  1. #1
    Junior Member
    Join Date
    Aug 2003
    Posts
    25

    A questions list ...

    I am trying to create a quiz and would like to have a list of questions in a text file that I could access and progress through as the user gets each question right e.g. q1=what is hardware, q2=what is software, etc. I've set up a dynamic text box with the variable name 'display' to hold the current question. How do I write the text file and then access the questions? Is this to do with loadVars?

    As a more comlicated version I wonder if it would be possible to rank the questions for hardness e.g. 1-3 for the user to select?

    Can anyone help please?

    Thanks
    Richard
    Last edited by richard101; 04-14-2005 at 11:43 PM.

  2. #2
    Space Monkey daarboven's Avatar
    Join Date
    Sep 2001
    Location
    in the basement boiling soap...
    Posts
    217

    Re: A questions list ...

    How do I write the text file and then access the questions?
    example----------
    Textfile mytext.txt:
    &questions=who is einstein?@what is relativity?@does god throw dices?&
    Code on frame 1:
    code:

    if(!counter){
    counter=0;
    }
    this.loadVariables("mytext.txt");
    questionlist=questions.split("@");
    mytextfield=questions[counter];
    stop();


    code on buttons in frame 1 (button 1=right, other button(s)=wrong):
    code:

    //button1
    on(release){
    counter++;
    mytextfield=questions[counter];
    }
    //other buttons
    on(release){
    //goto error message
    gotoAndPlay("some_frame_with_error_mssg")
    }


    concept:
    you load all questions in a single variable ansd split it into an array, this way you can easily access one q after thew other counting up th index on every right answer and display it to the dyn textfield.

    I wonder if it would be possible to rank the questions for hardness e.g. 1-3 for the user to select?
    yes. have as much arrays as you have hardness levels and a button to set the hardnes level into a variable (like hardness="easy").
    in your question reset, have an if statement checking the value of hardness....
    :::i am jacks complete lack of surprise:::

  3. #3
    Junior Member
    Join Date
    Aug 2003
    Posts
    25
    Thanks for your interest ....

    I can't seem to get it to work. Where does the 'questionlist' come in?

    I've attached my .fla file to this message if you have time to look (I can't seem to upload more than one file, but my text file is your copy).

    Richard
    Attached Files Attached Files
    Last edited by richard101; 04-16-2005 at 03:31 AM.

  4. #4
    Space Monkey daarboven's Avatar
    Join Date
    Sep 2001
    Location
    in the basement boiling soap...
    Posts
    217
    my bad, it has to be questionlist[counter].

    furthermore, there has to be a loop checking if the variables loaded.

    and last i build in a checker on the button to detect the end of the list and
    begin in the first position again.
    check the attached fla for details, it's all working fine.
    Attached Files Attached Files
    :::i am jacks complete lack of surprise:::

  5. #5
    Space Monkey daarboven's Avatar
    Join Date
    Sep 2001
    Location
    in the basement boiling soap...
    Posts
    217
    ps the .txt file needs to be modified:
    &questions=who is einstein?@what is relativity?@does god throw dices?&loaded=true&

    (wonder stimes where i got my mind...)
    :::i am jacks complete lack of surprise:::

  6. #6
    Junior Member
    Join Date
    Aug 2003
    Posts
    25

    Works OK

    Yep!

    Thanks - I've got there.

    I'm actually trying to solve this for a student of mine - she wants to create a snakes & ladders game, where progression depends on answering questions correctly. The degree of difficulty of the question (as mentioned earlier) would add an extra dimension to it. As you said if she creates a couple more variables and then uses an IF statement, it should do the trick.

    This thing about it taking time to load the text file - I suppose the best thing might be to load it into a Movie Clip right at the beginning - I've also been reading something about the LoadVars object ... this seems to offer possibilities!

    Richard

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center