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 Responses to “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

  2. Skelaxin says:

    Hey, interesting site, perhaps youd like to check out mine: Skelaxin

  3. ambien says:

    Hey, interesting site, perhaps youd like to check out mine: ambien

  4. Hi Guys

    Thanks for taking the time posting. MSN have finally launch blogs, what was with the delay?
    Phone Answering Personalised

    Cya
    Bruce

  5. Caiek says:

    So much spam (

  6. Ben says:

    LOL @ all the spam