First of all, just checking - Did you overwrite the id with something other
than "flashcontent" in your attributes object? If not, then you want:

var swf = document.getElementById("flashcontent");


Also - have you looked at the reference page examples for external
interface:
http://www.bobbyvandersluis.com/swfobject/testsuite_2_1/test_dynamic_com.htm
l


I think you want to try to call the EI method only once you have an onload
event on the window / page to ensure everything is ready and available, so
you could do something like:

<body onload="callEI();">

On write a separate onload function within your <head> functions like:

window.onload = function() 
{                       
        var swf= document.getElementById("ExternalInterfaceExample");
        if (swf && typeof swf.sendTextToFlash != "undefined")
        {
                swf.sendTextToFlash(text);
        }
}


Philip (pipwerks) or others may have a better solution than this...


Aran

-----Original Message-----
From: swfobject@googlegroups.com [mailto:swfobj...@googlegroups.com] On
Behalf Of Mohan
Sent: Friday, 30 January 2009 4:13 PM
To: SWFObject
Subject: Trying to access the flash element right after swfobject.embedSWF
results in error


Hello,

I have been trying to use this great library to embed some flash
dynamicly and then access the flash API via javascript
(ExternalInterface). The problem I am having seems to be, because I
try to access the flash element right after the call to
swfobject.embedSWF, the element does not seem to be ready yet.

For example, starting with the example code from
http://www.pipwerks.com/lab/swfobject/ExternalInterface/2.0/dynamic.html
(Thanks for the example!), if I were to modify the following
javascript in the dynamic.html global scope by trying to get at the
swf object I get an "swf is null". However the event handling code
that access the flash element still works ok, indicating that the
flash did get embedded ok.

swfobject.embedSWF("ExternalInterfaceExample.swf", "flashcontent",
"550", "200", "8", false, flashvars, params, attributes);
var swf = document.getElementById("ExternalInterfaceExample"); //added
line
swf.sendTextToFlash(text); //trying to use the flash object right
after embedding it

Is this because the flash element is not ready yet ? How would I
implement something that needs to be run right after the call to
swfobject.embedSWF ? The examples I have seen always make use of the
swfobject in some event handler and not right after the call to
swfobject.embedSWF. Any help would be greatly appreciated.

Mohan






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SWFObject" group.
To post to this group, send email to swfobject@googlegroups.com
To unsubscribe from this group, send email to 
swfobject+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/swfobject?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to