zipkundan
10-27-2009, 08:39 AM
Dear Friends,
I am trying to create a dynamic vertical menu with varying sub menu items in each main menu item. I am loading external xml file to get the menu items text. I stored data from xml in an Array wtih "for" loop.
Also I tried to duplicate a pre created movie clip. (movie clip name is "menuItem". Already placed on stage.) This was done fine.
All Ok so far. Now I am trying to combine these 2 things. But the "duplicateMovieClip" doesn't work.
Following is the code I am trying. Please advice what is wrong or what has to be done to achieve the goal.
//Following to load XML
var menuXML:XML = new XML();
menuXML.load("sample_menu_list_1.xml");
menuXML.ignoreWhite = true;
menuXML.onLoad = function(success) {
if (success) {
/* =================== */
var menuArray = new Array();
for (i=0; i<menuXML.firstChild.childNodes.length; i++) {
menuArray.push(menuXML.firstChild.childNodes[i].firstChild.nodeValue);
trace(menuArray.length);
//following for duplicating movie clip
var mcName:String = "menuItem"+(i+1);
trace("MC name is "+mcName);
var mcDepth:Number = i+1;
trace("MC depth is "+mcDepth);
var newMC:MovieClip = _root.duplicateMovieClip(mcName, mcDepth);
trace(newMC);
//duplicating movie clip ends
}
}
};
//For XML ends
I am very with actionscript. Any help is deeply appreciated.
Thanks.
I am trying to create a dynamic vertical menu with varying sub menu items in each main menu item. I am loading external xml file to get the menu items text. I stored data from xml in an Array wtih "for" loop.
Also I tried to duplicate a pre created movie clip. (movie clip name is "menuItem". Already placed on stage.) This was done fine.
All Ok so far. Now I am trying to combine these 2 things. But the "duplicateMovieClip" doesn't work.
Following is the code I am trying. Please advice what is wrong or what has to be done to achieve the goal.
//Following to load XML
var menuXML:XML = new XML();
menuXML.load("sample_menu_list_1.xml");
menuXML.ignoreWhite = true;
menuXML.onLoad = function(success) {
if (success) {
/* =================== */
var menuArray = new Array();
for (i=0; i<menuXML.firstChild.childNodes.length; i++) {
menuArray.push(menuXML.firstChild.childNodes[i].firstChild.nodeValue);
trace(menuArray.length);
//following for duplicating movie clip
var mcName:String = "menuItem"+(i+1);
trace("MC name is "+mcName);
var mcDepth:Number = i+1;
trace("MC depth is "+mcDepth);
var newMC:MovieClip = _root.duplicateMovieClip(mcName, mcDepth);
trace(newMC);
//duplicating movie clip ends
}
}
};
//For XML ends
I am very with actionscript. Any help is deeply appreciated.
Thanks.