user5589739
user5589739

Reputation:

Why as3 giving me syntax error in a for loop?

I'm new with actionscript and I keep getting syntax error with the following for loop:

for each (target:Target in targets) {
  if(target != null) {
    target.parent.removeChild(target);
  }
}

And I got this error message:

Syntax error: expecting in before colon.

What is the problem?

Upvotes: 1

Views: 36

Answers (1)

poke
poke

Reputation: 387667

You forgot to declare the variable, it should be:

for each (var target:Target in targets) {
    // …
}

Note the var.

Upvotes: 2

Related Questions