Hello, I’m new to addin XML to flash and I’m having some trouble. I’m trying to build a dynamic Accordian Menu, but I’ve run up on a stumbling block.
Here is my XML:
<menu>
<menuprams space=“2”>
<mainbutton lable=“1st Button” mainlink="">
<subitem sublable=“1st subitem” sublink=“http://www.someURL.com” />
<subitem sublable=“2nd subitem” sublink=“http://www.someURL.com” />
</mainbutton>
<mainbutton lable=“2nd Button” mainlink="">
<subitem sublable=“1st subitem” sublink=“http://www.someURL.com” />
<subitem sublable=“2nd subitem” sublink=“http://www.someURL.com” />
<subitem sublable=“3rd subitem” sublink=“http://www.someURL.com” />
</mainbutton>
</menuprams>
</menu>
Here is my AS:
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function() {
var space = this.firstChild.childNodes[0].attributes.space;
var nodes = xml.firstChild.firstChild;
var numItems = nodes.childNodes.length;
var menuheight = item._height;
trace(“There are “+numItems+” Menus”);
for (var i = 0; i<numItems; i++) {
duplicateMovieClip(“item”, “item”+i, i+10);
setProperty(“item”+i, _y, getProperty(“item”, _y)+(menuheight+Number(space))i);
set(“item”+i+".lableText", nodes.childNodes.attributes.lable);
set(“item”+i+".ID", i);
trace("This is Menu Number "+i);
}
//
};
xml.load(“test.xml”);
I can get the following to work and output:
There are 2 Menus
This is Menu Number 0
This is Menu Number 1
But I don’t know how to break it down further, I want to get the submenus:
This is Menu Number 0
1st subitem
2nd subitem
This is Menu Number 1
1st subitem
2nd subitem
3rd subitem
not sure what I have to do to get the other XML nodes named “subitem”
The goal here is that I’m going to marry it with some action script that will move all the other menus down when one button is unfolded EX:
This is Menu Number 0
1st subitem
2nd subitem
This is Menu Number 1
This is Menu Number 2
then:
This is Menu Number 0
This is Menu Number 1
1st subitem
2nd subitem
3rd subitem
This is Menu Number 2