Shouldn't it be "trace(child.title);" instead?

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Vayu Robins wrote:
Hi.

I am trying to build a dynamic menu system with unlimited submenus.

I have this from Colin Moock's book (Essential AS3) and it works fine.

var xml:XML = <course>
        <section>
            <title>Menu1</title>
            <section>
                <title>Menu1 - Sub</title>
                <section>
                    <title>Menu1 ­ Sub Sub</title>
                </section>
            </section>
        </section>
    </course>;

var xmlList:XMLList = xml.children();
parseStructure(xmlList);
function parseStructure(xml:XMLList):void
{
    for each (var child:XML in xml)
    {
        trace(xml.title);
        if (child.section != null) parseStructure(child.section);
    }
}

The problem for me arises when I add another section of menus like this:

var xml:XML = <course>
        <section>
            <title>Menu1</title>
            <section>
                <title>Menu1 - Sub</title>
                <section>
                    <title>Menu1 ­ Sub Sub</title>
                </section>
            </section>
        </section>

        <section>
            <title>Menu2</title>
            <section>
                <title>Menu2 - Sub</title>
                <section>
                    <title>Menu2 ­ Sub Sub</title>
                </section>
            </section>
        </section>
    </course>;

Is it the xml that is wrong?

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

Reply via email to