Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't set global array

Status
Not open for further replies.

copeZero

Programmer
Aug 31, 2007
46
0
0
CA
This is the darnest think, so why is it that one cannot set a global array in a function, ive tried many ways but nothing works... grrr, i just can't figure this out...

Code:
var xmlDoc:XML = new XML(); 
System.useCodepage = true; 
xmlDoc.ignoreWhite = true; 

xmlDoc.onLoad = function(ok:Boolean) { 
if (ok) { 

var num:Number = this.firstChild.childNodes.length; 
var num2:Number = 0;
var test1 = this.firstChild.childNodes[0].childNodes[0].attributes.modname;

// sometimes the first value does not exist, so skip it
if (test1.length==0) {num2=1;}
var f:Number=0;

for (var i = num2; i < num; i++) { 

_global.aLabels[i]= this.firstChild.childNodes[i].childNodes[0].attributes.modname;

// if i check for _global.aLabels[0] or [1] many frames 
//later i get undefined.
// At this spot in this function if i:
// trace(_global.aLabels[0]);  I get a value
// so why can i use the array later?  Thanks


}
	   
   } else { 
       trace("XML did not load"); 
   } 
};

xmlDoc.load("test.xml");
 
figired it out...
in the code above instead of using an array i'm calling a function to do the work:

var f:Number=0;

Code:
for (var i = num2; i < num; i++)
{
f = f +20;
chekbx(this.firstChild.childNodes.childNodes[0].attributes.modname, f);
}



Code:
function chekbx(val,num){
var depth:Number = this.getNextHighestDepth();

var val2:Number = num;

var cchItem:mx.controls.CheckBox;

var param bject = {_x:100,_y: val2+100,label:val};
cchItem = this.createClassObject(CheckBox, "cch"+val2, depth++, param );
cchItem.addEventListener("click", oListener);
trace(20 * val2 + 100);

cchItem.move(400, val2 + 100);

};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top