On 13/11/2010 16:24, Cor wrote:
Thanks Paul,

Yes, but how would I "dive" through in depth arrays?

var nestedArrays:Array=[  0, 1, 2, 3, [4,5,[7,8,[9,10],11]], 12];

arrayDescender(nestedArrays);

function arrayDescender(pArr:Array, pDepth:uint=0):void {
    for (var i:uint=0; i< pArr.length; i++){
        if (pArr[i] is Array){ // node
            arrayDescender(pArr[i], pDepth+1);
        } else { // leaf
            trace ("level "+pDepth+" ["+i+"] = " + pArr[i]);
        }
    }
}

















Regards
Cor


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Paul Andrews
Sent: zaterdag 13 november 2010 17:14
To: Flash Coders List
Subject: Re: [Flashcoders] How to iterate through arrays

On 13/11/2010 15:17, Cor wrote:
I am trying to create a menu with 5 levels deep submenus.
Sounds like a UI nightmare for the user.
My best guess is to do this with an array with a bunch of arrays in it,
which also contain arrays, etc.
And now I have to iterate through all the levels of the arrays.
So I need some example how to iterate regards the amount of arrays and
items
in the arrays.

Suggestions please. (Any better way is also appreciated).
Check out recursive functions.
Regards
Cor




_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Geen virus gevonden in het binnenkomende-bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 9.0.869 / Virusdatabase: 271.1.1/3249 - datum van uitgifte: 11/10/10
20:34:00

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to