thanks!

________________________________________
From: flashcoders-boun...@chattyfig.figleaf.com 
[flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Paul Andrews 
[p...@ipauland.com]
Sent: Wednesday, March 17, 2010 3:10 AM
To: Flash Coders List
Subject: Re: [Flashcoders] Recurisve Functions

On 16/03/2010 23:49, Paul Andrews wrote:
> On 16/03/2010 20:19, Lehr, Theodore wrote:
>> Any good tuts on recursive functions in as3?
>>
>> I am basically making an org chatr and would love to have one
>> function to run through some xml to build the org chart (import a pic
>> and name) and place them in the right position based on the xml. My
>> xml would look something like:
>>
>>
>> <person pid='5' pparent='0' pimage='image5.jpg'>
>> <person pid='4' pparent='5' pimage='image4.jpg'>
>>
>>
>> I have the code working from one person.... I just would love to find
>> a way to make a recursive function to go through all the xml entries....
>> _______________________________________________
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
> Your XML should really be more like:
>
> <person pid='5' pimage='image5.jpg'>
> <person pid='4' ' pimage='image4.jpg'/>
> </person>
>
> You should then be able to iterate through .

I should add that your original XML could be used, but then your just
using XML to hold an old-fashioned tree list and it's not really an XML
relationship problem (since your original XML is just a flat list) but a
problem of traversing a tree of links. Your original XML is just an
array with references to other links in the array. The thing that makes
it difficult to handle is that your links point in the wrong direction -
you can't easily tell where the children are for a given element. If I
had to use the original XML, I would load them into an array which also
had forward pointers. Initially those pointers would be unset and I
would then search out all the children for a given element and continue
until I had mapped all children. Then I can build the tree from the root
element - I can recursively descend the tree.

To space the tree out you need to know the spacing characteristics of
the level below.

Not sure that helps.

Paul
>
>
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to