I’m wanting to store four boxes in an array and iterate over all of them in a ‘for’ loop placing each at a different location. I’m using the isometric library As3IsoLib. Here is my code so far.
var BOX1:IsoBox = new IsoBox();
var BOX2:IsoBox = new IsoBox();
var myArray:Array = new Array(BOX1,BOX2);
for (var occr:IsoBox in myArray){
But I’m getting an error at my ‘for’ loop line which is
Description Resource Path Location Type
1067: Implicit coercion of a value of type String to an unrelated type as3isolib.display.primitive:IsoBox. isometric.as /main/src line 51 Flex Problem
This line:
Should be:
That will solve the error. This is happening because it is intended to loop over properties of an object, not indexes of an array. So there is a strange type requirement.
The “for each” loop is much better suited to looping over elements of an array.