for loop going mad
Ive got this for loop, but for some weird reason it malfunctions:
-when triggered, it runs infinite times.
-it only triggers when segmenten1 or segmenten3 are 0, which is weird, because it should also work when segmenten0 and 2 and 4 are 0...
here is the for loop:
stage.addEventListener(Event.ENTER_FRAME,addmetaal);
function addmetaal (evt:Event) {
for(var animteller=0;animteller<5;animteller++){
if (this["segmenten"+animteller]==0) {
trace("segmenten"+animteller)
for(var teller6=0; teller6<4; teller6++) {
var enzym_mc:EnzymAnim1=new EnzymAnim1();
var metaal_mc:MetaalAnim1=new MetaalAnim1();
Vijanden.push(enzym_mc);
Vijanden.push(metaal_mc);
metaal_mc.rotation=enzym_mc.rotation=Math.random()*360;
metaal_mc.x=enzym_mc.x=xco[animteller];
metaal_mc.y=enzym_mc.y=yco[animteller];
addChildAt(enzym_mc,numChildren-90);
addChildAt(metaal_mc,numChildren-90);
}
}
}
}
do you know why this is malfunctioning?
it seems to me like that when any of the segmenten variables hits 0, it should trigger 2nd for loop, and repeat that 4 times.
the xco and yco are arrays which store values for the x and y coordinates for spwaning the addchilds, this works fine.
the segmenten variables are declared as following:
var segmenten1:Number=17, segmenten2:Number=17, segmenten3:Number=17, segmenten4:Number=17, segmenten0:Number=17;
please help me out here