Wednesday, July 18, 2007

Actionscript/Javascript Communication

Now its much easier to communicate with Flash from Javascript and vice versa using ExternalInterface class.

You can create any function in Flash & then use the ExternalInterface class to register that function to call from the browser.

I am giving a step by step explanation to achieve the desired functionality.

First and foremost import the package using the statement given below -

import flash.external.*;

& then call the following function to register the function

ExternalInterface.addCallback("callASFunction", null, asFunction);

Explanation: The first parameter "callASFunction" is the name which will be used to call the function from the browser and the third parameter is the actual name of the function created in Flash. You can always keep the second parameter as null.

No comments: