开发者

How can i invoke my own javascript API on my SWF dynamically embeded using swfOject?

I am using the swfObject library to dynamically embed a MP3 player i've made in Flash CS5. In the .fla file, i've declared a list of methods that 开发者_开发百科can be called via Javascript (using the flash.external.ExternalInterface flash class).

That's not the problem since all these function work properly when called from Google Chrome's console. However, swfObject provides a way to invoke javascript API only if the .swf has been statically included (i.e. using swfobject.registerObject() ) but i can't find a way to achieve the same goal when the .swf is dynamically included (i.e. using swfobject.embedSWF() ).

Thanks in advance for your help and contibutions :)


When you are using swfobject.embedSWF, you can specify the ID of the swf object in the attributes parameters :

swfobject.embedSWF(swfUrl, id, width, height, version, expressInstallSwfurl, flashvars, params, attributes, callbackFn)

Example :

swfobject.embedSWF(
    "YourFlash.swf", "WhereToPlaceThis", "0px", "0px", "10.0.0",
    "expressInstall.swf", {}, {}, { id : "IdOfTheSWF" },
    function () {
         var SWF = document.getElementById("IdOfTheSWF"); // That's your SWF //
         SWF.yourFlashFunction(); // And you can invoke function //
    }
);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜