views:

141

answers:

3

I am trying this code:

entLoop:for(var i:*in entities) {
    for(var i2:*in ignoreEntities) {
        if(entities[i].type==ignoreEntities[i2]) {
            continue entLoop;
        }
    }
}

Why is it not working? The error is:

Target of continue statement was not found.

+2  A: 

I may be wrong, but it seems that the continue instruction doesn't work with for...in loops.

Compiler doesn't throw any error with this code :

entLoop:for(var i:Number = 0 ; i < 2 ; i++) {
  for(var i2:Number = 0 ; i2 < 2 ; i2++) {
    if(true) {
      continue entLoop;
    }
  }
}

(I replaced your condition by true since I don't have the definitions for your entities and ignoreEntities arrays)

Zed-K
Seems I was right, if I believe this link : http://blog.coursevector.com/notes-loopstatement-labels : "If you’re going to use labels, you’ll want to make sure you’re using regular for or while loops. (A bug has been filed and will hopefully be fixed soon.)" - posted in January 2010
Zed-K
That's so wrong, continue shouldn't be used in this case, just check the actionscript reference (it's the same for most languages) http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/statements.html
Theo.T
A: 

I think you have to use break LABEL; instead.

From live docs : http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/statements.html

Theo.T
Do u know the difference between "continue" and "break"?
M28
well break; "breaks" out of the loop whereas continue; "continues" (i.e. jumps) to a label.
Theo.T
Do u know the difference between "continue", "break" and "goto"?
M28
I'm super curious now, please explain instead of minus pointing :(, I must have got missed out something for a long time.
Theo.T
A: 

ha deleted my answer as its not relevant my bad - no point in storing my dumbness online :) thanks for making the correction :P

Ben Fhala
Actually, there _are_ labels. Just take a look at the link I posted in my comment above.
Zed-K
http://help.adobe.com/en_US/AS3LCR/Flash_10.0/statements.html#continuemy bad your totally right i had no clue this is even part of the language that's actually amazing i'm going to play with it now :P
Ben Fhala