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.

Justin Johnson
  • 30,978
  • 7
  • 65
  • 89
  • A discussion about the problem: http://www.actionscript.org/forums/showthread.php3?p=766215 –  Mar 18 '10 at 19:17

2 Answers2

2

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
  • 991
  • 2
  • 8
  • 23
  • 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 Mar 18 '10 at 19:29
  • 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 Mar 18 '10 at 20:16
-2

I think you have to use break LABEL; instead.

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

Theo.T
  • 8,905
  • 3
  • 24
  • 38
  • 1
    Do u know the difference between "continue" and "break"? –  Mar 18 '10 at 20:02
  • well break; "breaks" out of the loop whereas continue; "continues" (i.e. jumps) to a label. – Theo.T Mar 18 '10 at 20:10
  • 1
    Do u know the difference between "continue", "break" and "goto"? –  Mar 18 '10 at 20:51
  • I'm super curious now, please explain instead of minus pointing :(, I must have got missed out something for a long time. – Theo.T Mar 18 '10 at 22:28