AS3 Warning Fix: 1102, null used where a Number value was expected.

This is a common warning issue. When trying to reset a number back to a default, null, or empty value. You think that you can just set the variable to Null. AS3 handles numbers oddly thou.

var foo:Number;

public function resetFoo():void {
    foo = null;
}

This code will produce the following warning during/after builds.

1102: null used where a Number value was expected.

The correct way to reset a Number is to set it to NaN “Not a Number”.

var foo:Number;

public function resetFoo():void {
    foo = NaN;
}

This will remove the warning.

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s