Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Version 8 of the Flash Player includes a class named ExternalInterface that revolutionizes Flash scripting by greatly simplifying JavaScript-to-Flash communication and Flash-to-JavaScript communication. ExternalInterface defines a static call() function for calling named JavaScript functions and obtaining their return values. It also defines a static addCallback() method for exporting ActionScript functions for use by JavaScript. ExternalInterface is documented in Part IV.
To demonstrate the ease of scripting with ExternalInterface, let's convert Example 23-4 and Example 23-5 to use it. Example 23-6 lists the converted ActionScript code, and Example 23-7 shows the converted JavaScript code (the <object>, <embed>, and <form> tags are not altered from Example 23-5 and are omitted here).