Getting Started with ExternalInterface


The ExternalInterface class is the preferred way in which you make JavaScript to Flash and Flash to JavaScript function calls when you are publishing Flash 8 content. The class is only available starting in Flash Player 8. If you plan to publish content to a previous version of Flash Player, you'll need to use something such as the Flash/JavaScript Integration Kit. You can read more about the Flash/JavaScript Integration Kit at http://weblogs.macromedia.com/flashjavascript.

ExternalInterface is designed to work with ActiveX as well as the NPRuntime API. What that means is that it works with InternetExplorer 5.0 and higher on Windows as well as with Netscape 8.0 and higher, Mozilla 1.7.5 and higher, and Firefox 1.0 and higher on Windows and Macintosh, and Safari 1.3 and higher on Macintosh. At the time of this writing, NPRuntime does not yet work with Opera. If you are building an application that must work in a browser that does not support ActiveX or NPRuntime, you can consider the Flash/JavaScript Integration Kit.

The ExternalInterface class is in the flash.external package. That means that if you want to reference the class you'll either have to use the fully qualified class name (flash.external.ExternalInterface) or you'll have to import the class before referencing it. Importing the class is generally recommended because it makes your code more succinct and readable. The following import statement imports the class so that you can simply reference the class as ExternalInterface at any point following the import statement. The following import statement is implied in every short example in the remainder of this lesson:

   import flash.external.ExternalInterface;





Macromedia Flash 8 ActionScript Training from the Source
Macromedia Flash 8 ActionScript: Training from the Source
ISBN: 0321336194
EAN: 2147483647
Year: 2007
Pages: 221

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net