Jason beat me to the punch on this one, but, I was going to say too, in
all seriousness that this doesn't work if each child has two parents; as
well, having step parents is another ball game too.
Take for example if a person has 6 kids with another person, than in
your model, each person, would have to have 6 kids underneath them, and
that would duplicate a ton of data, which with regard to bandwidth
concerns can be a problem when you are breaking down a family tree.
Just imagine a scenario where my six kids, each have six kids, that have
six kids, but now you have to duplicate that under the second parents,
and you will see what I mean.
The best way to do this for two parents, is to have each person be an
individual, and give them a motherId and fatherID.
If there are no IDs it's an orphan, and the start of a new tree.
On 3/19/2010 4:07 PM, Merrill, Jason wrote:
I would write the XML this way instead:
<people>
<person firstName'"Bob" lastName="Smith">
<person firstName="Timmy" lastName="Smith" />
<person firstName="Jenny" lastName="Jones">
<person firstName="Sal" lastName="Stephens" />
</person>
</person>
<person firstName="Tom" lastName="Williams">
.etc.
Also, recursive functions call themselves - and then break when some
value or condition is reached.... for yours, add to your object, and
then check to see if there are child nodes in the xml below it, if so,
call the function again to add more, if not, break out of the function.
However, this will only get you through the top level nodes and one of
the top level nodes's sub nodes - not the others - I actually can't
think of how to get into the OTHER sub-nodes - though I know there are
people on this list who do. I know what some people do is make the first
pass on the first level, then the second pass on the second, and so on,
adding to the object as they go. Don't ask me to send you an example
though.
Recursive functions are also quite hard to wrap your head around. :)
Jason Merrill
Bank of America Global Learning
Learning& Performance Solutions
Join the Bank of America Flash Platform Community and visit our
Instructional Technology Design Blog
(note: these are for Bank of America employees only)
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Lehr,
Theodore
Sent: Friday, March 19, 2010 3:54 PM
To: Flash Coders List
Subject: [Flashcoders] Recursive:Part II
So I have this xml:
<allPeople>
<person>
<personFirstName>Bob</personFirstName>
<personLastName>Smith</personLastName>
<person>
<personFirstName>Timmy</personFirstName>
<personLastName>Smith</personLastName>
</person>
<person>
<personFirstName>Jenny</personFirstName>
<personLastName>Smith</personLastName>
</person>
</person>
<person>
<personFirstName>Tom</personFirstName>
<personLastName>Williams</personLastName>
<person>
<personFirstName>Sa</personFirstName>
<personLastName>Williams</personLastName>
</person>
</person>
To start I am just trying to recursively go through this to grab the
first names. I am trying:
createPeople(peopleXML)
function createPeople (_xml:*):void
{
var xmlList:XMLList-_xml.children();
for each (var fn_xml in xmlList) {
createChart(fn_xml);
trace(item_xml);
}
}
I am wondering - am I on the right track? Does the xml look well-formed
for doing what I am trying to do?
Thanks!
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders