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\DraggableTreeRow.as:
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 toplevel.as, so it’s not recognized by the compiler as a valid function. This gave us two options: adding it to toplevel.as or calling it dynamically.

Adding it to toplevel.as 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) {
stopRowDrag();
}

Enjoy!

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

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

6 thoughts on “Using ASnative in AS2

  1. Thank you for the coments on your website. Can you recomend a good location for me to find cheap medicines? My mama is not well right now. Can you advice? Thank you.

    Pablo Villarino

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>