Exposing SWF methods

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Exposing SWF methods

Post 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.
User avatar
PHPHorizons
Forum Contributor
Posts: 175
Joined: Mon Sep 14, 2009 11:38 pm

Re: Exposing SWF methods

Post 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?
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Re: Exposing SWF methods

Post 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.
User avatar
PHPHorizons
Forum Contributor
Posts: 175
Joined: Mon Sep 14, 2009 11:38 pm

Re: Exposing SWF methods

Post by PHPHorizons »

Can you post a link to the page?
Post Reply