I'm making an XML powered menu for my website and it works fine as a stand-alone movieclip on my stage. But when I nest it inside a few more movieclips it stops working and I don't see why.
The original path was "_level0.m5d" but now since it's in a few more clips it should be "_level0.portfolioNavMC.p5dMC.m5d" but that doesn't seem to work.
Here's my full script so you guys can give it a look over:
The only reason I can think of why this might not work is because "portfolioNavMC" is dynamically attached to the root timeline, but even when I just drag it onto the stage and apply the Instance Name that way it still doesn't work!
Anyone have any ideas why I can't get this thing to work?
The paths look pretty messy, and you really don't need them, so I chopped them down. The problem with the XML is that childNodes[0] seemed to be empty. I don't know much about using XML in Flash, so you'll have to look at that yourself. Here's how I changed the code, and at least one item came up correctly.
code:
var xmlData:XML = new XML();
//Get rid of these long paths - we don't need them.
xmlMenu.ignoreWhite = true;
xmlData.load('m5d.xml');
//Create a new variable that will act like a pointer to replace these long paths.
var dPath:MovieClip = this;
xmlData.onLoad = function():Void {
//Again, no long path needed. qtd will be created at this level, as long as we don't prefix it with anything
//For some reason, childNodes[0] comes up empty, so I had to use [1];
qtd = this.childNodes[1].childNodes.length;
//Also, this is coming up as 3, when really you only want 1. I'm not too hot on XML, so I don't know how to fix this.
for (i=0; i<qtd; i++) {
//xmlMenu exists at this leve, so again no long path needed
xmlMenu.duplicateMovieClip('xmlMenu'+i, _level0.portfolioNavMC.p5dMC.m5d.getNextHighestDep th());
//Here, I have to use dPath to reference this level since you want to use array access operators
dPath['xmlMenu'+i]._y += i*16;
//Again, I had to change these to [1] to get any kind of output
dPath['xmlMenu'+i].t = this.childNodes[1].childNodes[i].childNodes[1].firstChild;
dPath['xmlMenu'+i].texto.text = dPath['xmlMenu'+i].t.nodeValue;
dPath['xmlMenu'+i].link = this.childNodes[1].childNodes[i].attributes.link;
dPath['xmlMenu'+i].onRollOver = function() {
loadMovie(this.link, this.previewMC);
};
dPath['xmlMenu'+i].onRollOut = function() {
unloadMovie(this.previewMC);
};
}
xmlMenu.unloadMovie();
};
Hope this helps.
"If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton