I am working on a Flash application and need some assistance with elements of the AS3 code that handle the input from the xml file that holds the reading and questions about it. I'm parsing the .XML and loading it into Array variable(s). This works when I trace the variable "myxml" -- it shows everything nicely.

I'd like to know how to retrieve values of CIRCLING.QUESTION[i] and CIRCLING.ANSWER[i] from the variable "myxml" they have been parsed and loaded into, without getting an error message (because I won't know how many there are, I'm not sure how to write the loop controlling this...I think it's something to do with length but am not certain.

In English -- how do I display the questions that go with any particular sentence, since I don't know how many there are? The questions are also displayed on a different frame from the sentence they go with, if that matters.

Here is the xml input:
Code:
<?xml version="1.0" encoding="utf-8"?>

<STORY title="Cinderella">

<SENTENCE number="01">
	<ENGLISH>Cinderella is sad.</ENGLISH>
	<IMAGE>images/cinderella01</IMAGE>
	<AUDIO>cinderella01.mp3</AUDIO>
<CIRCLING>
//this one happens to have two questions; there could be up to 15//
	<QUESTION>
		<ENGLISH>Who is sad?</ENGLISH>
		<AUDIO>cin01Q01.mp3</AUDIO>
	<ANSWER>
		<ENGLISH>Cinderella is sad.</ENGLISH>
		<AUDIO>cin01A01.mp3></AUDIO>
	</ANSWER>
        </QUESTION>
	
	<QUESTION>
	<English>Why is she sad?</ENGLISH>
	<AUDIO<cin01Q02.mp3</AUDIO>
        <ANSWER>
            <ENGLISH>Because she has ugly sisters.</ENGLISH>
            <AUDIO>cin01A02.mp3></AUDIO>
           </ANSWER>
</CIRCLING>

</SENTENCE>


<SENTENCE>
<ENGLISH>Cinderella has two older sisters.</ENGLISH>
<IMAGE>images/cinderella02</IMAGE>
<AUDIO>cinderella02.mp3</AUDIO>

<CIRCLING>
//this one has only one question//
	<QUESTION>
		<ENGLISH>Who has two older sisters?</ENGLISH>
		<AUDIO>cin02Q01.mp3</AUDIO>
        <ANSWER>
	<ENGLISH>Cinderella does.</ENGLISH>
	<AUDIO>cin02A02.mp3></AUDIO>
	</ANSWER>
	</QUESTION>
</CIRCLING>
		
</SENTENCE>
</STORY>
The problem I'm having (as a person new to Flash and XML) is that there may be different numbers of questions under the <CIRCLING> nodes.

I would like to have a frame that displays all the questions under <CIRCLING>, one by one, in random order, in response to a button press each time, and displays/plays their corresponding answers and audio files, again in response to a button press, depending on which QUESTION is loaded. Repeats of the same question are ok but anyway the randomization is a later concern; for right now, I'd be happy just to get all the questions there might be under any particular SENTENCE.CIRCLING to display in turn.

I can code the buttons to make the content appear if I limit things to SENTENCE.CIRCLING.ENGLISH[0] and so forth (using specific integers, not variables in [ ]); my problem is how to load the XML elements for the <CIRCLING> content (making that [0] into an [i] or something for the loop) since I do not know how many child nodes <CIRCLING> might have for a given <SENTENCE>. There might be none, or there might be up to 15. (Something with "length" maybe? I've tried snippets from some Web sites and tutorials but so far no luck.)

Thank you greatly for any assistance!