Hi I’m trying to build an xml navigation which will at this point only work for a specific site’s purposes but in the future I want to expand and make something available for everyone which is fully customizable… This is half business / half hobby because this is the first time I’m working with XML and Flash.
I’m having trouble making the movie clips buttons dynamically. I would like to build the buttons in the second frame of my clip, but I cant seem to get an array from the function and well, check out the code and I’ll explain more at the bottom:
function loadXML(loaded) {
if (loaded) {
//find out how many main categories there are
_global.CatsNum = this.firstChild.childNodes[0].childNodes.length;
//refers to categories
//declare new array for holding main categories
var mainCats:Array = new Array();
//set font style for menu options
var mainMenuFormat:TextFormat = new TextFormat();
mainMenuFormat.font = "Futura Lt Bt";
mainMenuFormat.size = 12;
mainMenuFormat.bold = true;
mainMenuFormat.color = 0xFFFFFF;
x = 10;
tx = 10;
newXbg = Stage.width;
newXmenu = Stage.width-10;
bgLevel = 49;
//add all main categories names to array
for (i=0; i<CatsNum; i++) {
mainCats.push(this.firstChild.childNodes[0].childNodes*.childNodes[0].firstChild.nodeValue);
}
mainCats.reverse();
//create text fields
for (i=0; i<CatsNum; i++) {
_root.createTextField("mainCat"+i, i+50, x, 0, 200, 20);
eval('mainCat'+i).text = mainCats*.toUpperCase();
eval('mainCat'+i).autoSize = "left";
eval('mainCat'+i).setTextFormat(mainMenuFormat);
eval('mainCat'+i).selectable = false;
eval('mainCat'+i).embedFonts = true;
tx += eval('mainCat'+i)._width+20;
x = tx;
//Right Align Menu Text
eval('mainCat'+i)._x = newXmenu-eval('mainCat'+i)._width;
newXmenu -= eval('mainCat'+i)._width+20;
//fills background color
if (i%2 == 0) {
this.menu_bg_color = 0xF23030;
} else {
this.menu_bg_color = 0x572600;
}
createEmptyMovieClip('menu_bg_pen'+i, bgLevel);
eval('menu_bg_pen'+i).moveTo((eval('mainCat'+i)._x-10), 0);
eval('menu_bg_pen'+i).beginFill(this.menu_bg_color, 100);
eval('menu_bg_pen'+i).lineTo(((eval('mainCat'+i)._width+eval('mainCat'+i)._x)+10), 0);
eval('menu_bg_pen'+i).lineTo(((eval('mainCat'+i)._width+eval('mainCat'+i)._x)+10), 20);
eval('menu_bg_pen'+i).lineTo((eval('mainCat'+i)._x-10), 20);
eval('menu_bg_pen'+i).lineTo((eval('mainCat'+i)._x-10), 0);
eval('menu_bg_pen'+i).endFill();
bgLevel -= 1;
}
/*onEnterFrame = function(){
//trace(CatsNum);
for (i=0; i<CatsNum; i++){
eval ('menu_bg_pen'+i).onRollOver = function(){
eval ('menu_bg_pen'+i)._alpha = 50;
trace("over"+i);
}
eval ('menu_bg_pen'+i).onRollOut = function(){
eval ('menu_bg_pen'+i)._alpha = 100;
trace("out"+i);
}
//trace(i);
}
}*/
} else {
//trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("collection.xml");
So that builds the navigation fine, aligned to the right of the stage, just how I want it, but my main problem is returning the array mainCats. I would like to use this array in Frame 2 of my movie, but for some reason it returns as undefined even if I declare it as global!
Any help, suggestions, comments are greatly appreciated