Using ASnative in AS2

We had a need to use ASnative in a real application today for the first time. To our surprise, the first time we compiled we received this error message:

**Error** C:\CVSA\source\view\controls\
Line 99: There is no method with the name 'ASnative'.
           if (ASnative(800, 2)(1)!=1) {

Total ActionScript Errors: 1 	 Reported Errors: 1

Turns out ASnative isn’t in, so it’s not recognized by the compiler as a valid function. This gave us two options: adding it to or calling it dynamically.

Adding it to makes the code less portable because all machines that compile the application need to have this modification. Instead, we opted for dynamic invocation, as in the following example.

if (["ASnative"](800, 2)(1)!=1) {


For more information on ASnative see this entry on the Flashcoders Wiki.

(btw, I’ll post on why I’m using it later)