Namespaces
Variants
Actions
Revision as of 09:31, 26 July 2012 by hamishwillee (Talk | contribs)

Archived:Using the externalInterface class of Flash in WRT

Jump to: navigation, search
Article Metadata

Code Example
Article
Created: Risalmin (15 Sep 2010)
Last edited: hamishwillee (26 Jul 2012)

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

184 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved