A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: array question

  1. #1
    Member
    Join Date
    Jul 2000
    Posts
    87
    Hi All!
    For the Quizz game I'll have a different question and 3 answers on each frame. Now,I want to keep all my framelabels in array
    and after I randomly pick up the question

    Set Variable: "myvar" = random(5)+1
    Go to and Play ("myquestionframe"&myvar)

    delete it from array and never come back to this frame again....

    what would be a way to do it?????
    ThaNk YOu
    Ilia

  2. #2
    Senior Moderator
    Join Date
    Apr 2000
    Location
    Sheffield, UK
    Posts
    3,881
    Create an array for all the correct answers on the first frame of the main timeline too:

    set varaible:"answer1"= "yes"
    set varaible:"answer2"= "no"
    set varaible:"answer3"= "yes"
    set varaible:"answer4"= "yes"
    set varaible:"answer5"= "no"

    And also put set varaible: "z" = "1"
    and then call (random)

    Then on the main timeline create a movieclip,inside the movieclip on the first frame put:
    set variable: "/:currentframe" = Getproperty("/",_currentframe)

    Then on the second frame put:

    Go To And Play(1)Now put this movieclip on a newlayer that spreads across all frames.

    Then on the first frame of the main movie put:

    Call (Random)

    The second frame on the main timeline should be given a label "Random"

    On this frame we are going to create 5 unique random numbers:

    Set Variable: "i" = 1
    Loop While (i <> 6)
    Set Variable: "rnd" = Random (5)+1
    Set Variable: "x" = 1
    Loop While (x <> (Length(Temp)+1))
    If ((Substring (Temp, x, 1)) eq rnd)
    Set Variable: "rnd" = ""
    End If
    Set Variable: "x" = x+1
    End Loop
    If (rnd ne "")
    Set Variable: "Temp" = Temp & rnd
    Set Variable: "i" = i + 1
    End If
    End Loop


    Then we have a varaible called temp which now contains 5 unique random numbers.

    We now want to go to and play that unique random number so underneath we put:

    Go to And Play (Substring(temp,z,1))+ 2
    set varaible "z" = z + 1

    Now all you have to do is create 5 frames after for your five questions and in each put a button, three questions and a textfield called "answer" On each button put:

    On(press)
    if (Eval("answer" & currentframe)= answer
    Call(random)
    set varaible:"correct" = correct + 1
    End If
    End on

    And also put a stop action on each frame.

    Now create your questions and answers and put then out your answers in the array!!

    ANd then put a textfield on the maintimleine called "correct" this will display the number of correct answers.

    That should now work!!I made the game quickly and then wrote the explanation straight away!! so if anything doesnt work it is because i havent typed it correctly or missed something out!!(Hopefull i havent)


    Regards Flashguru



    p.s if it doesnt work i will send you my version whcih i knocked up for you!!!












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