Calling Javascript functions from Flash

Calling Javascript functions from Flash is very easy. We use a class called ExternalInterface. Here is ActionScript code:

import flash.external.*;

button1.addEventListener(MouseEvent.CLICK, buttonHandle);

function buttonHandle(event:MouseEvent)

Here flash.external is a package where the class ExternalInterface is found.
The code is very simple. Event listener to button is added. And call is a method of ExternalInterface class, the parameter passed to call() is a name of the Javascript function.

The Javascript function is an alert message:

function showMessage()
    alert("Hi from flash");

Javascript function called from Flash


One thought on “Calling Javascript functions from Flash

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s