Archived:Using the externalInterface class of Flash in WRT
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.
We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.
Article Metadata
Code Example
Source file: Media:externalInterfaceExample.zip
Article
Created: Risalmin
(15 Sep 2010)
Last edited: hamishwillee
(14 May 2013)
This draft document will describe how to use the externalInterface class in Adobe Flash for communicating between a Web Runtime Widget (JavaScript) and a Flash SWF (ActionScript). A good example of such implementation is the On demand Web TV – have your favorite channels with you
Contents |
HTML
Add an id to the Flash object's embed tag:
<object
id='swfObject'
height='100%'
width='100%'
data='myFlashApp.swf'
allowscriptaccess='always'
allowFullScreen='true'
usefullscreen='true'
type='application/x-shockwave-flash'
loop='false'
name='swfObject'>
<param name="canHandleException" value="true" />
</object>
ActionScript
ActionScript 2
//required to use the externalinterface class
import flash.external.*;
//Add a function call that can be accessed from javascript
ExternalInterface.addCallback("hello",this, hello);
//and the actual function
function hello(){
//do something
}
ActionScript 3
//required to use the externalinterface class
import flash.external.*;
//Add a function call that can be accessed from javascript
ExternalInterface.addCallback("hello", hello);
//and the actual function
function hello(){
//do something
}
Calling the function in Flash from JavaScript
function hello() {
document.getElementById("swfObject").hello();
}
Example implementation
You can download an example FLA and WRT widget from this link


(no comments yet)