Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Member Tristessa's Avatar
    Join Date
    Nov 2004
    Location
    Kingston, Ontario
    Posts
    94
    Member #
    8215
    I posted a thread about a week ago asking help for making questions in my flash game appear randomly, I got the randomizing part done perfectly.

    I’ve been working on a simple true or false quiz game. The questions must appear randomly.

    I’m currently using this code for randomizing which works perfectly!!!!


    This array is on the first frame:

    code:

    choices = ['q1', 'q2', 'q3', 'q4', 'q5', 'q6', 'q7', 'q8', 'q9'];


    On the “next question” button:


    code:

    on (release) {

    if (choices.length) {


    frameNumber = choices.splice(random(choices.length), 1);


    gotoAndPlay(frameNumber);


    } else {
    gotoAndPlay("end");
    }
    }



    There’s only one little thing, I have each question in this quiz numbered. Now that the questions are randomized... the question numbers are now out of order and they should be sequential.

    On each frame with a question there is a dynamic text box. The code on that frame reads:

    stop();
    radbuttons.gotoAndStop(1);
    theName = "Question 1";


    The text box reads: Question 1... or whatever question you're at in the game.

    Is there a way where I can get these question numbers to appear sequentially even though the questions themselves load randomly?

  2.  

  3. #2
    Senior Member zionlocke's Avatar
    Join Date
    Jan 2003
    Location
    .: l33t Basement :.
    Posts
    736
    Member #
    483
    Liked
    3 times
    Solution: Have an integer outside of any method in root and increment with your button. start at either zero or one depending on how you implement. good luck. if you need help, let me know.

    Good to see that you cleaned up the code a bit. Yes, splice is a much easier way to do the same thing, although it might be a little hard to setup a "play again" sequence after the quiz is over.

    To add the integer to the string printed above questions do something like this:

    dynamicString = "Question " + qInt

    dynamicString would be the variable for the dynamic text box
    qInt would be the global int on a frame found in _root

    Let me know if you need help again.
    Cheers, zionlocke :chinese:
    Links: Zion Creation | Blog

  4. #3
    Member Tristessa's Avatar
    Join Date
    Nov 2004
    Location
    Kingston, Ontario
    Posts
    94
    Member #
    8215
    Thank you very much, I'll let you know when I get it to work.
    You've been a great helper!

  5. #4
    Member Tristessa's Avatar
    Join Date
    Nov 2004
    Location
    Kingston, Ontario
    Posts
    94
    Member #
    8215
    Just letting you know that I got the script to work

    I put in a very simple code on each of the frames that contained the dynamic text.

    I can paste the code here if you like for future reference for other people.

  6. #5
    Junior Member shiningpixel's Avatar
    Join Date
    Nov 2003
    Posts
    28
    Member #
    3777
    Tristessa - why not go ahead and paste the code anyway?

    It might be what one of us is looking for...

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Though since this was a year and a half ago... :-D

  8. #7
    Junior Member shiningpixel's Avatar
    Join Date
    Nov 2003
    Posts
    28
    Member #
    3777
    yeah, realized that after I posted - I'm catching up, slowly, in so many ways


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:51 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com