nnnnngh
[potlatch2.git] / net / systemeD / halcyon / MapPaint.as
index e67d2901e09c2ad9a177011936f0146b29e4907f..9c4f132bb83baaad3bb1c798d7540f42bb892702 100644 (file)
@@ -83,10 +83,14 @@ package net.systemeD.halcyon {
                                }
                        
                                // update index
+                               // (we do it in this rather indirect way because if you alter sublayerIndex directly
+                               //  within the loop, it confuses the iterator)
+                               var toUpdate:Array=[];
                                for (index in sublayerIndex) {
                                        ix=Number(index);
-                                       if (ix>sublayer) { sublayerIndex[index]++; }
+                                       if (ix>sublayer) { toUpdate.push(index); }
                                }
+                               for each (index in toUpdate) { sublayerIndex[index]++; }
                                sublayerIndex[sublayer]=lowestAbovePos;
                        }