0

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 :)

3
  • doesn't a good document.getElementById do the trick? Commented Apr 11, 2011 at 16:42
  • i tried it but it only works from the console, not when the document.getElementById() code is inside my <script> tags Commented May 5, 2011 at 8:04
  • You have to write the script tag after the element you want to get in your page. Commented May 6, 2011 at 13:50

1 Answer 1

1

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 //
    }
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.