Hello Kirupa Cats!
I am building a menu from an XML file, and I’m cool with cyclying thru the xml data to create menu items.
For every menu item in my XML file, I’m using attachMovie to insert a movie clip called menuitem from my library into a movieclip called menuholder. This works no problem, my menuholder movieclip is poplulated with as many menuitem movieclips from the library as designated by the xml data.
However, inside the library movieclip called menuitem, I have another movieclip on its stage, called mc_menuImage. I want to load an image into that movieclip, and I’m taking the URL for the image from the XML data.
My problem is I can’t seem to figure out how to fully identify the movieclip mc_menuImage to load the image. It may have something to do with the fact that the library movieclip is being loaded dynamically, but the movieclip inside the library movieclip exisits pysically on the stage. I don’t know…here’s the code I’m working with:
THE CODE:
var xmlMenu:String = “menu.xml”;
menuholder = createEmptyMovieClip(“menuholder”, -1);
var xmlMenuData:XML = new XML();
xmlMenuData.ignoreWhite = true;
xmlMenuData.load( xmlMenu );
xmlMenuData.onLoad = function(loaded) {
if (loaded) {
var mImage:Array = new Array();
var mRootNode = this.firstChild.childNodes;
totalMenuItems = mRootNode.length;
// fill array
for (var i = 0; i<totalMenuItems; i++) {
mImage.push(mRootNode*.attributes.menuImage);
}
}
//make the menu
for (var i = 0; i<totalMenuItems; i++) {
var menuitem = menuholder.attachMovie(“menuitem”, “menu”+i, i);
menuitem.id = i;
/* now here I thought I could just do this: /
menuitem.mc_menuImage.loadMovie(mImage);
/* but that doesn’t work… */
};
When I trace menuitem I get this: _level0.menuholder.menu0, _level0.menuholder.menu1, etc, so I figured the syntax menuitem.mc_menuImage would identify the movieclip inside menuitem, but to no avail. Maybe it has something to do with levels, I’m not sure…
So I don’t know, any suggestions? Thanks so much!!!