I decided I better start a new thread for this one…
I’m using a hard-coded array to create a menu:
clientArray = new Array("autoaero", "consumer", "education", "utilities", "financial", "government", "healthcare", "industrial", "infocom", "media", "natural", "nonprofit", "realestate", "services", "technology", "travel");
But I would like to pull the array from an external text file. I’m attaching two files - the hard-coded one works, but the file loading external data isn’t quite there even though running a trace gives me a string that looks just like the string in the hard-coded version.
I know I’m real close but I can’t think of anything else to change. Here’s the not quite working code:
clientArray = {};
clientArray.items = new Array();
clientArray.data = [];
loadArray = new LoadVars();
loadArray.onLoad = function() {
fl = this.category;
clientArray.items = fl.split(",");
clientArray.init();
}
loadArray.load("menu.txt");
//clientArray.init = function() {
//trace(this.items);
//trace(this.items.toString());
//}
//clientArray = new Array("autoaero", "consumer", "education", "utilities", "financial", "government", "healthcare", "industrial", "infocom", "media", "natural", "nonprofit", "realestate", "services", "technology", "travel");
clientArray.init = function() {
trace(this.items);
clientMenuText = new TextFormat();
clientMenuText.font = "Verdana_embed";
//Must use embedded font
clientMenuText.size = 8;
clientMenuText.color = "0xB2B2B2";
//
//var totalNavHeight = clientArray.length * 15;
var totalNavHeight = 7*15;
//
var menu_mc = this.createEmptyMovieClip("menu_mc", 1);
for (n=0; n<clientArray.length; n++) {
navName = clientArray[n].toLowerCase();
var curMC = menu_mc.createEmptyMovieClip(navName, n+100);
curMC.createTextField("nav_txt", n+100, x_pos, yStart+(n*navHeight), 100, 0);
curMC.nav_txt.text = clientArray[n];
curMC.nav_txt.embedFonts = true;
curMC.nav_txt.selectable = false;
curMC.nav_txt.autoSize = "left";
curMC.nav_txt.setTextFormat(clientMenuText);
//trace(eval(navName));
//trace(curMC);
}
};