Page 1 of 1

Exposing SWF methods

Posted: Tue Jun 15, 2010 5:01 pm
by JellyFish
Is there a way to expose various JavaScript methods to an embed element made available by a SWF? I have this flash file I didn't create with very little documentation on it. I've been able to discover some methods by merely guessing. Is there some way I can inspect the API it gives me?

[EDIT]
From the research I've been doing (google), I found out that in flash this is called ExternalInterface. So apparently, in ActionScript, you create an ExternalInterface object and add callbacks using the addCallback method. Every callback is then available to JavaScript. What I'd like to know is how I can list all the callbacks made available.

Re: Exposing SWF methods

Posted: Tue Jun 15, 2010 11:46 pm
by PHPHorizons
Hello JellyFish,

Is there an object that you can get a hold of? I would assume that there would be an object that you use to call these methods on and that object can definitely be inspected. I would recommend using any javascript debugger for this. I personally use FireBug which is an addon to firefox. But there are others you can use with various browsers.

You could also resort to making a foreach loop and iterate over all the properties of the object. All methods that that object has will be visible to you.

Code: Select all

var someDivElement = document.getElementById('someDivElement');
foreach (var x in flashObject) {
if (flashObject.hasOwnProperty(x)) {
 someDivElement.innerHTML += flashObject[x];
}
}
Does that help?

Re: Exposing SWF methods

Posted: Wed Jun 16, 2010 11:13 pm
by JellyFish
The object is an HTMLEmbedElement and I try this:

Code: Select all

var swf = document.getElementById('theswf');
for (var i in swf)
{
console.log(i);
}
And gives me a list of various methods and properties the HTMLEmbedElement has, however none of the callbacks I already know of are listed.

You see, in flash you can create an ExternalInterface object and then add callbacks to it using the addCallback method. Once a callback is added, JavaScript can then call that callback using the HTMLEmbedElement of the flash's SWF. These callbacks aren't the same as regular DOM properties and methods. So a "for each" syntax wont detect them. But this doesn't stop me from asking here if there is a way to detect them.

Re: Exposing SWF methods

Posted: Thu Jun 17, 2010 7:27 am
by PHPHorizons
Can you post a link to the page?