I am trying to get the indexOf value from an array that is populated from an XMLList
With the following code:
I will get the following trace results:
excludeLayers Array: Transition Areas,Elevation,Hanford,Infrastructure,Buildings
indexOf layer : -1
However, if I hard code the Array values:
I will get the following trace results:
excludeLayers Array: Transition Areas,Elevation,Hanford,Infrastructure,Buildings
indexOf layer : 2
So, for some reason, it is not working as hoped unless I hard code the array values and not if I populate it from my XMLList. Thought it might have something to do with quotes (as I need the quotes to hard code since there are spaces), but have tried adding quotes to no avail.
However, if I iterate through the array and compare to the list of operational layer names, the matching values show as equal so not sure whey they are not equal in the indexOf test.
In any case, does what I doing wrong happen to jump out at anybody that could maybe point me in the right direction?
R_
With the following code:
Code:
private var excludeLayers:Array;
private var exclude:Boolean = false;
excludeLayers = [];
var elyrList:XMLList = configXML..excludelayer;
for (var el:int = 0; el < elyrList.length(); el++) {
excludeLayers.push(elyrList[el].@name);
}
trace("excludeLayers Array:", excludeLayers);
trace("indexOf layer :", excludeLayers.indexOf("Hanford"));
excludeLayers Array: Transition Areas,Elevation,Hanford,Infrastructure,Buildings
indexOf layer : -1
However, if I hard code the Array values:
Code:
private var excludeLayers:Array;
private var exclude:Boolean = false;
excludeLayers = ["Transition Areas","Elevation","Hanford","Infrastructure","Buildings"];
trace("excludeLayers Array:", excludeLayers);
trace("indexOf layer :", excludeLayers.indexOf("Hanford"));
excludeLayers Array: Transition Areas,Elevation,Hanford,Infrastructure,Buildings
indexOf layer : 2
So, for some reason, it is not working as hoped unless I hard code the array values and not if I populate it from my XMLList. Thought it might have something to do with quotes (as I need the quotes to hard code since there are spaces), but have tried adding quotes to no avail.
However, if I iterate through the array and compare to the list of operational layer names, the matching values show as equal so not sure whey they are not equal in the indexOf test.
In any case, does what I doing wrong happen to jump out at anybody that could maybe point me in the right direction?
R_