hello
i’ve been trying to rewrite this code (it’s from flash 8 tutorial) in as3. the problems started with phrasing xml file. here’s what i did so far.
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadXML);
loader.load(new URLRequest("menu_nav.xml"));
var ID:Array = new Array;
var DisplayName:Array = new Array;
var LinkType:Array = new Array;
var LinkValue:Array = new Array;
var topMenuNum = 0;
function loadXML(e:Event):void
{
var xml:XML = new XML(e.target.data);
trace ("the number of total children is... " + xml.children().length());
var i = 0;
while ( i < xml.children().length()) {
ID.push(xml.children()*.attributes()[0]);
DisplayName.push(xml.children()*.attributes()[1]);
LinkType.push(xml.children()*.attributes()[2]);
LinkValue.push(xml.children()*.attributes()[3]);
if (ID* == "TM") {
topMenuNum = topMenuNum +1;
}
i = i +1;
}
trace ("the total number of top menu items is... " + topMenuNum);
}
now i have some serious problems with this part (it should be before i=i+1). it’s to keep track of how many submenu items there will be.
set ("submenu_Finish_" + ID* , i);
if ( eval(".submenu_Start_" + ID*) == undefined )
{
set ("submenu_Start_" + ID* , i);
Total_subs = Total_subs + 1;
}
set ("Total_Items_in_Submenu_" + ID* , eval( "submenu_Finish_" + ID*) - eval( "submenu_Start_" + ID*) + 1);
there was _global in front of every variable. i removed it coz i dont think it would affect the code at this point