hey. i’ve been trying to get this to work for a few days and i’ve had no luck. apparently i’m not as smart as i thought i was. what i’m trying to do is make a menu system. i’ve loaded the xml correctly, i think, and have traced my info at like, every stage… everything returns correctly as far as i can tell: my variables return correctly at each time through the loops, tracing returns the right amount of children nodes in each parent node.
so, my problem comes at duplicating the movie clips. in my library i have a menuItem linked movie clip that my menu links are made from.
what i want to happen is the xml loads, i make a “parent” link, a “subMenu” holder for that parent’s children nodes/links, those nodes links are loaded into the menu. for example:
my xml has a parent node of “ruth” with children “adam, jane” and a parent node “jim” with children “tina, james, paul”. we go through, see that there are two parent nodes, so we create the link “ruth” and a sub menu holder “ruth_kids”. in “ruth_kids” i have links “adam” and “jane”.
pretty straight forward… but i’m getting confused with the levels stuff… i can load some of the children correctly with a few of the parents. if i switch some of the depth stuff, i get all the parents but no children… or no parents and all the children. AHHH … help!!
the only frame in my movie and all the AS:
fla, xml, and XMLSA.as can be found here:
Stage.scaleMode = "noScale";
Stage.align = "TL";
#include "lmc_tween.as"
import XMLSA;
//-------------------------------
// Load XML
//-------------------------------
portfolio = new XMLSA();
portfolio.load("xml.xml");
portfolio.onLoad = function(ok){
if (ok) {
// do something
_root.makePortfolio();
} else {
// error branch
trace("error");
}
}
stop();
//-------------------------------
// Do stuff with the XML
//-------------------------------
function makePortfolio (){
//Make Main Menu Holder
var subCount:Number = 1;
var mainMenu:MovieClip = _root.createEmptyMovieClip("mainMenu",_root.getNextHighestDepth());
//Make Main Menu Items in Main Menu Holder
for (var i=0; i<portfolio.$xml.childNodes.length; i++) {
trace("
PARENT");
trace("section name: " + portfolio.$xml.childNodes*.attributes.section);
trace("****************** making main menu... i is "+i);
var menuItem:MovieClip = _root.mainMenu.attachMovie("menuItem","menuItem_parent"+i,mainMenu.getNextHighestDepth());
this.kids = portfolio.$xml.childNodes*.childNodes.length;
menuItem.Name.text = portfolio.$xml.childNodes*.attributes.section + " i have " + kids + " children.";
menuItem._x = 40;
menuItem._y = 20*i;
menuItem._alpha = 100;
menuItem.Name.autoSize = "left";
//menuItem.count = i;
//Make Sub Menu Holder for each parent item
var subMenu:MovieClip = _root.mainMenu.createEmptyMovieClip("subMenu"+i,mainMenu.getNextHighestDepth());
//load sub menu items into respective sub menu
for (var r=0; r<portfolio.$xml.childNodes*.childNodes.length; r++){
trace("****************** making sub menu... i is "+i);
var menuItemSub:MovieClip = ['subMenu'+i].attachMovie("menuItem","menuItem_sub"+r,['subMenu'+i].getNextHighestDepth());
menuItemSub.Name.text = portfolio.$xml.childNodes*.childNodes[r].firstChild;
menuItemSub._y = 10*subCount;
menuItemSub._alpha = 30;
menuItemSub.Name.autoSize="left";
subCount++;
};
};
// slide the menu to see what's in what layer
mainMenu.slideTo(90,90,1);
};