views:

126

answers:

2

Is there a way to query an embedded flash element to determine the available methods that can be executed on it via JavaScript?

Edit: It appears that in IE it's as simple as

for ( i in flashNode ) {
    alert(i);
}

After much clicking, they will be some of the very last members enumerated.

Still not able to determine this in Firefox though.

A: 

I believe it works the same way in FF and other browsers, but you may need to get the reference to your swf element differently than IE.

IE will use an object tag, generally with an id, and ff/safari/etc will use the embed tag, and since you aren't supposed to be the same id on two elements, people generally use the name attribute instead of an id attribute on the embed tag.

If you are using something like SWFObject to embed your swfs, then you should only get one or the other (object or embed) and whichever one gets written will have the id attribute set with whatever you specify, so then you could iterate over the object.

Geoff
Nope, you can use document.getElementByID('whatever-flash-element') to get the flash element in all browsers.Also, I tried the same method in FF3 but no luck.
Justin Johnson
Well I poked around a bit and couldn't find any obvious way to iterate over the things. I think you might be stuck on this one.If you have access to the swf you could try to decompile it and look for external references, or you could ask the creator of the swf for the list of functions :)
Geoff
+1  A: 

While it is possible to get the callbacks by enumerating the <object> DOM node in IE, they are mixed in with all the other properties of the DOM node and they are unable to be progamatically distinguished without keeping a list of known properties to compare them against and then taking the difference of the two sets.

This approach is questionable since properties can be arbitrarily added to any DOM node. Worse, it only works in IE. Firefox (and possibly others) does not return callbacks as a property of the <object> DOM node.

Justin Johnson