knowledge.lapasa.net

Greater Toronto Area Flash Platform Developer Blog

Notes: AS3 JavaScript communication

TAGS: None

There are number of examples on the web. Last time I had to do this was back in the fscommand days. Some of the the key things I need to remember the next time I deal with JS<->AS communication are

When Flash is calling out to the external JavaScript, the ActionScript code must have:

ExternalInterface.call(”{externalJavaScriptMethodName}”, {parameters});

When calling from JavaScript into the internal Flash client, the Flash client must expose methods using:

ExternalInterface.addCallback(”{jsMethodName”, asFuncObjReference);

and the JavaScript code must properly reference the movie

function thisMovie(movieName) {
if (navigator.appName.indexOf(”Microsoft”) != -1) {
return window[movieName];
} else {
return document[movieName];
}
}

function playClip(url)
{
alert(url);
thisMovie(”${application}”).playClip(url);
}

ABOUT THE AUTHOR
Mark Lapasa is an experienced (5yrs+) Flex/Flash/ActionScript Developer. He has product experience developing client-side application software for the Financial CRM and Online Gaming Industries.

Leave a Reply

© 2009 knowledge.lapasa.net. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.