Flash Hacks. 100 Industrial-Strength Tips & Tools Free Open Book

Flash Hacks. 100 Industrial-Strength Tips & Tools

Previous Section  < Day Day Up >  Next Section

Hack 83 ASnative( ) Back Door

figs/expert.gif figs/hack83.gif

All ActionScript method calls are mapped to a table of internal functions built into the Flash Player. Directly access the internal function table via the undocumented ASnative( ) method.

The Flash Player supports methods that are not exposed in the ActionScript API. That is, not only are some functions undocumented, they don't even have names! Instead, they are stored in a function table and accessed by indexing into that table.

The undocumented ASnative( ) function can access internal ActionScript methods, including those not findable using ASSetPropFlags( ) [Hack #82] . It appears to access functions in a lookup table by using two indexes:

ASnative(a, b);

or, in some cases, an optional argument list:

ASnative(a, b)(args);

where index a is an integer correlated to an ActionScript class, index b is an integer correlated to a method within the class, and args is one or more argument(s) associated with the method.

For example, using 200 for index a seems to access the Math class, so varying index b offers access to the Math class's methods. Try these:

trace(ASnative(200, 0)(-4.567)); // Displays 4.567

trace(ASnative(200, 9)(144));    // Displays 12

From these tests, you can conclude that ASnative(200, 0) accesses the Math.abs( ) method, and ASnative(200, 9) accesses the Math.sqrt( ) method. That's fine, but why would we want to use a cryptic ASnative( ) call to access documented ActionScript methods?

Most (a, b) indexes into ASnative( ) yield something that is exactly equivalent to a documented method of a documented class. However, some indexes have no exposed ActionScript equivalent, in which case the only way you can access them is via the ASnative( ) back door.

ASnative(800, b) is one such set of indexes. Index 800 seems to access input/output functions, including undocumented methods of the Mouse class [Hack #62] .

Final Thoughts

The "find the undocumented Flash Player features before Macromedia tells us about them" game is a favorite among longtime Flash users. See the FlashCoders Wiki (http://chattyfig.figleaf.com/flashcoders-wiki/index.php?ASNative) for a blow-by-blow account of this hunt to date and additional insights into the ASnative( ) method and the parameters it accepts.

    Previous Section  < Day Day Up >  Next Section
    Index: [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O][P][Q][R][S][T][U][V][W][X][Z]


         Main Menu
    Flash Hacks
    Table of Contents
    Copyright
    Credits
    Foreword
    Preface
    Chapter 1. Visual Effects
    Chapter 2. Color Effects
    Chapter 3. Drawing and Masking
    Chapter 4. Animation
    Chapter 5. 3D and Physics
    Chapter 6. Text
    Chapter 7. Sound
    Chapter 8. User Interface Elements
    Chapter 9. Performance and Optimization
    Chapter 10. ActionScript
    Hacks #74-85
    Changes in Flash MX 2004
    Hack 74 External Script Editors
    Hack 75 Strict Typing and Casual Scripters
    Hack 76 Code Hints
    Hack 77 Clone an Object
    Hack 78 An Idle Timer (Timeout Event)
    Hack 79 Fast ActionScript Searches
    Hack 80 Lock the actions Layer
    Hack 81 Debug with trace( )
    Hack 82 Undocumented ActionScript
    Hack 83 ASnative( ) Back Door
    Hack 84 Obscure Operators
    Hack 85 Import ASC Files as XML
    Chapter 11. Browser Integration
    Chapter 12. Security
    Colophon
    Index


    More Books
    PHP Hacks
    Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
    The Koran (Holy Qur'an)
    Macromedia Flash 8 Bible
    Search Engine Optimization for Dummies
    YouTube Traffic
    PHP 5 for Dummies
    Harry Potter and The Chamber of Secrets
    Harry Potter and the Sorcerer's Stone
    The Pilgrim's Progress
    Wireless Hacks
    Flash Hacks. 100 Industrial-Strength Tips & Tools
    PayPal Hacks. 100 Industrial-Strength Tips and Tools
    Amazon Hacks
    Pdf Hacks
    The Da Vinci Code
    Google Hacks
    The Holy Bible
    Windows XP For Dummies
    Harry Potter and the Half-Blood Prince
    Seo Book
    Upgrading and Repairing Networks
    Macromedia Dreamweaver 8 UNLEASHED
    Windows XP Annoyances
    Windows XP Hacks
    Microsoft Windows XP Power Toolkit
    Teach Yourself MS Office In 24Hours
    iPod & iTunes Missing Manual
    PC Hacks 100 Industrial-Strength Tips and Tools
    PC Overclocking, Optimization, and Tuning - 2th Edition
    PC Hardware In A Nutshell 3rd Edition
    PC Hardware in a Nutshell, 2nd Edition
    Upgrading and Repairing PCs
    Google for Dummies
    MySQL Cookbook
    Teach Yourself Macromedia Flash 8 In 24 Hours
    PHP CookBook
    Sams Teach Yourself JavaScript in 24 Hours
    PHP5 Manual
    Free Games Paper Airplanes
    500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele