Eliminating repeat calls from a list

Ask a Question related to Macromedia Director Lingo, Design and Development.

  1. #1

    Default Eliminating repeat calls from a list

    Hi,
    I am a student working on a childrens game. The concept is a spelling bee. A picture pops up, a voice speaks the word, and there is a field to input the text to spell the word. I have 50 words right now, in a list that associates the word, picture and sound. then I have a random number -random(50)- generated to pull a random item out of the list, each level of the spelling bee is only 10 questions long. I want to eliminate the chance of the same item being pulled from the list during play.

    Here is my current script to generate the word picture and sound. (I shortened the database to make it easier to read, but there are 50 items in the list, each item containing the three elements.)



    on displayquestion
    pDatabase = [["acorn", "acornpic", "acornsound"],["apple", "applepic", "applesound"],["bag", "bagpic", "bagsound"],["ball", "ballpic", "ballsound"]]
    pVariable = random(50)
    pSet = pDatabase[integer(pVariable)]
    sprite(4).member = pSet[2]
    sprite(4).locH = 320
    sprite(4).locV = 260
    sprite(4).visible = true
    pCorrectAnswer = pSet[1]
    end

    on checkquestion
    if member("field").text = pCorrectAnswer then
    pCorrect = pCorrect + 1
    pQuestionnum = pQuestionnum + 1
    member("field").text = ""
    updatescore
    else if member("field").text <> pCorrectAnswer then
    pincorrect = pincorrect + 1
    pQuestionnum = pQuestionnum + 1
    member("field").text = ""
    updatescore
    end if
    gPress = false
    displayquestion
    end

    Again, I want to eliminate the chance of the same item being called from the list twice. Any help is greatly appreciated! THANKS!

    Brad


    WickedSense webforumsuser@macromedia.com Guest

  2. Similar Questions and Discussions

    1. How to Display Repeat List In Spry Tab Content
      Hello, I am new to Spry. I thought I could just create an XML dataset, Insert a Spry Tabbed Panel, and then insert a Spry repeat list inside the...
    2. eliminating like items in dynamically loaded list boxes
      Hello- I am currently learning coldfusion and I have just connected to a MS Access database and I have created some dynamically loaded list boxes....
    3. background-repeat: repeat-x in HTML? Please help!
      I want to have a "centered page" look full screen...I have made them using layers and CSS but if I need it to work in most browsers how do I do the...
    4. Can we place repeat region on dynamic list/menu
      Hey y'all: Having some problems with inserting all fields in a table from SQL db. While we manage to call up teh 5 rows from SQL using a list...
    5. eliminating red eye
      I downloaded my pictures to iphoto and eliminated the "red eye" in some of the pictures. When I open them in photoshop the red eye is still present....
  3. #2

    Default Re: Eliminating repeat calls from a list

    delete the item after you use it

    and so, instead of random 50 you should
    call random in to the remaining questions..

    pVariable should be
    pVariable = random( pDatabase.count() )

    and at the end of the displayquestion
    pDatabase.deleteAt( pVariable )

    ... just noticed ..
    you should not initialize the list in the same handler that you use for
    selecting and deleting (for obvious reasons.... )
    so on startmovie should be a betterPlace ... or on beginsprite if you are
    using a behaviour to control the questions..


    hope this helps

    gabriel


    Gabriel Guest

  4. #3

    Default Re: Eliminating repeat calls from a list

    Wow! Great, the advice worked out, no more duplicates!
    Also, since there are three levels, and each level is scripted at a seperate marker (different locations in other words) I decided to establish my 3 databases like this within a movie script.

    global gDatabase1, gDatabase2, gDatabase3

    on preparemovie

    gDatabase1 = [["acorn", "acornpic", "acornsound"],["apple", "applepic", "applesound"], etc.

    gDatabase2 = [["airplane", "airplanepic", "airplanesound"],etc.

    gDatabase3 = [["airplane", "airplanepic", "airplanesound"],etc.
    end

    This is working great, i thought i'd mention it because I am unsure of the pros and cons of using globals compared to properties



    WickedSense webforumsuser@macromedia.com Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139