Most of the flash developer have the idea about ExternalInterface API for accessing the javascript function from Flash and it can be support to call Flash function from the javascript. From this feature we can control the functionality from the javascript. For accessing the flash function first we need to get the flash swf object instance and then call the flash function. Please note browser may be differ for getting the object from the web page. So use relevant tag for getting the swf object from HTML page. The javascript function can be added in inside of HEAD tag in the HTML /Web page as
function getFlashMovie(movieName)
{
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function loadLogo()
{
getFlashMovie("Flash Instance Name").UploadLogo();
}
in Flash add the callbackfunction to the External Interface API as folows
ExternalInterface.addCallback("UploadLogo", UploadLogo);
public function UploadLogo():void
{
//Your code here
}
The some of the points to be noted for acessing the flash functions as follows
1.The flash function can be called from the javascript function must be public scope.
2.Use the flash instance name as same as Object Tag id property as well as Embed Tag id and name property
3. Object Tag id property and Embed Tag id as well as name property must be same name.
Then accessing the flash function from the javascript and control the swf functionality from javascript function.
No comments:
Post a Comment