This is kind of hard to explain…
I’ve got an XML document that contains names and images for an image gallery, with a menu on the main page, allowing people to click the menu item to display the corresponding image and name.
[AS]
for (i=0; i<total; i++) {
thename* = items*.childNodes[0].firstChild.nodeValue;
image* = items*.childNodes[1].firstChild.nodeValue;
var myItem = item_mc.main_btn;
item_mc.menuitem_txt.text = thename*;//place text on menu items
myItem.onRelease = displayCharacter;//goes to function which passes variable according to content
myItem.startPoint = i;//tells previous/next buttons where in the XML document we started so it knows which characters come before and after
}
[/AS]
I need to be able to assign each of these items a number. This COULD be done by adding a line to the XML doc with a number, then adding an extra line to the ActionScript like this: number* = items*.childNodes[2].firstChild.NodeValue;
The trouble is, it is intended that the XML document will be updated regularly, with new items being added in-between exisiting items, therefore, if I had item number 1, followed by item number 2, then wanted to add an extra item after 1, I’d have to call it 2, then rename the existing 2 to 3, and so on.
What I need to do is somehow dynamically give each item a number in Flash as the XML is loaded so number* = ???
(it needs to be number* because * is used later to refer to items)
Can anyone help with telling me how to dynamically give each item a number in this way?? Thanx