Using For Loop with repeated visible test

Subscribe to Using For Loop with repeated visible test 4 posts

avatar for Degraiver Degraiver 9 posts
Flag Post

Getting straight to the point this is what i want to do:

for (var i:Number=0; i<28; i++)
		{
			if (isMap[i] == 1)
			{
				display.label[i].visible = true;
			}
			else
			{
				display.label[i].visible = false;
			}
		}

I want it to check an array slots then compare it to the display.label1, then display.label2 so on so forth. Except, it doesn’t work =\ anything im doing wrong? Or does flash not suppose this kind of coding?

 
avatar for Degraiver Degraiver 9 posts
Flag Post

nvm i figured it out.
the problem was the display.label[i].visible
should have been display["label"+i].visible

 
avatar for Eu_Plon_Ka Eu_Plon_Ka 259 posts
Flag Post

Are you trying to compare two arrays, because that kind of seems like what you are asking for. Your code will go through the isMap, and make changes.

 
avatar for Degraiver Degraiver 9 posts
Flag Post

all it is doing is checking the variable in the array. there are 28 variables in the array isMap. it only checks if the value is 1 or 0, if it is 0 object is hidden, if variable in isMap is 1, that object is visible. the display["label"+i] is looked as display.label1 which would the object it will make visible or hidden. so all of the objects are from 1-28 at the end. If that makes things more clear.