2 Replies Latest reply on Feb 20, 2008 1:05 AM by scrattis

    Creating a quiz form with actionscript

    scrattis
      What is the most efficient way to make this:

      I have an XML-file of questions (well they are in database but I generate a XML-list of them) and answers.
      Format:
      <question id="x" question="lorem lipsum">
      <answer id="x" right="0/1" answer="lorem lipsum">
      <answer id="x" right="0/1" answer="lorem lipsum">
      <answer id="x" right="0/1" answer="lorem lipsum">
      <answer id="x" right="0/1" answer="lorem lipsum">
      </question>
      .....
      ....

      And I want to create a form that has total of 40 questions and each of them has 4 answers. The order of these is random.

      Logically it would go with somekind of for loop where i go through the nodes and create all the form elements. But is that so and how to do that?
        • 1. Re: Creating a quiz form with actionscript
          ntsiii Level 3
          1) create a custom component to display each question. It should take the question node as a property typed as XML I like using setter functions. This component must handle the entire display of a single question, including the answer list.
          2) Inside a VBox, decalre an <mx:Repeater> assign the XMLList to the dataProvider property.
          3) Inside the repeater, declare your custom component, and pass in a reference to the entire currentItem(which will be the question xml node)

          IF you find that 40 questions is too slow to render, then set the itemCount proptety to some number like 5, and instead of having a big scrolling list, implement "Next Page" and "Previous Page" buttons to traverse the list of 40 questions by setting the start and end index of the repeater.

          Tracy
          • 2. Re: Creating a quiz form with actionscript
            scrattis Level 1
            I managed to do this without custom components, but using repeaters still. Everything is fine, but now i should be able to make radiobuttongroup with dynamic ID:s like one to fourty.

            I have a question number in xml each question, but when i try to add it to ID with {}, flex gives me error: .... is not a valid identifier.