swf : calling functions declared via ExternalInterface.addCallback fails · Issue #846 · fancyapps/fancyBox · GitHub

There are two points of failure here :

1 ) the id of the SWF object element is currently set to ‘fancybox-swf’ which contains one of the proscribed characters according to Adobe documentation : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html

excerpt : "Note: When embedding SWF files within an HTML page, make sure that the id attribute is set and the id and name attributes of the object and embed tags do not include the following characters: . – + * / \"

2 ) in some browsers you must get a reference to the object element and in others you must get a reference to the embed element in order to call the ActionScript function (‘callback’) from JavaScript. The embed element is not currently given an id at all.

I see three levels of solution :

1 ) Fix the ‘-‘ in the id of object and add a different id to embed in order to facilitate a ‘roll-your-own’ solution

2 ) Add an API that returns a reference to the Flash Player by function name : like getFlashPlayerForFunctionCall( functionName )

3 ) Full boat solution ‘callActionScriptFunction( functionName, paramArray ) and then use ‘apply’ to call the function and passthrough/return the result

I documented my workaround on Stack Overflow : http://stackoverflow.com/questions/22875712/externalinterface-callback-not-working-in-fancybox

via swf : calling functions declared via ExternalInterface.addCallback fails · Issue #846 · fancyapps/fancyBox · GitHub.

zheng dai
Author: zheng dai


Posted

in

by

Tags: