3597 Duplicate variable definition.

The compiler has detected a duplicate definition for a variable. This can lead to unexpected results. ActionScript does not support block level scoping of variables. All variables defined within a function body exist within the same scope, even if they are defined within an if statement, while statement, for statement, and so on: for example, the following code redeclares the variable x twice:

function test() {
	var x:Number = 10;
	if (true) {
	    for (var x=0; x < 5; x++)  // warning here, this is the second defintion of x
	trace(x); // 5, not 10.  The last value set by the for loop above is the current value of x

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s