1. In the Flash add the following method with to parameters.
ExternalInterface.addCallback(functionName, parameters)
functionName: this is the function name in the javascript.
parameters: parameters you might need for that function.
example:
ExternalInterface.addCallback('tellFlashToPlay','playVideo');
ExternalInterface.addCallback('tellFlashToPause','pauseVideo');
2. create the functions within Flash
private function playVideo():void
{
video.play();
}
private function pauseVideo():void
{
video.pause();
}
3. create functions in javascript to call Flash.
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
4. on click call functions in flash:
getFlashMovie("nameOfFlashMovie").tellFlashToPlay();
getFlashMovie("nameOfFlashMovie").tellFlashToPause();
links:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html#addCallback()
http://www.viget.com/inspire/bi-directional-actionscript-javascript-communication/
No comments:
Post a Comment