Get ExternalInterface definitions in Javascript
Asked Answered
M

5

9

Is there a way to get a list of the exposed functions from a Flash object? For example, you could get a list of all methods in an object by executing:

for (var i in object) {
  if (typeof object[i] == "function") {
    console.log(i);
  }
}

The only issue is that this won't expose any methods registered through the ExternalInterfaces API. I can try and see if the function exists (object['method']) and it tells me it is a function, but I would have to guess every existing method in this manner.

NOTE: Obviously, I don't have access to the actionscript.

Meghannmegiddo answered 12/1, 2010 at 21:3 Comment(0)
H
2

Just hit this question, a tad to late it seems, but I'll post an answer anyways ;) Using IE10 (windows 7) it worked perfectly fine for me to list all my methods like so:

var obj = document.getElementById('flashObj');
for(var prop in obj){
  var fx = obj[prop];
  if(obj.hasOwnProperty(prop) && (typeof fx == 'function') && /eval\(instance/.test(fx)){
    console.log(prop)
  }
}

Note that this did not work in Chrome or Firefox and only with the exact regexp since IE10 does not report "native code" as the other browsers do.

Humboldt answered 17/6, 2013 at 11:19 Comment(0)
P
1

The problem is even worse: the information is neither available in ActionScript. You register a new function as ExternalInterface.addCallback('foo', foo) and you can not list already registered callbacks.

Precipitant answered 20/4, 2010 at 21:59 Comment(0)
C
1

Just a guess but see if it works. All the ExternalInterface functions should be defined in the global namespace. Try embedding the SWF in an HTML page and get all the Javascript functions defined for the page after the page has loaded. List of global user defined functions in JavaScript?

The list of functions should be those defined in the SWF file.

Canopus answered 28/4, 2010 at 10:35 Comment(0)
C
0

I guess the only way to go is to parse the SWF file bytecode and try to gather the calls to ExternalInterface.addCallback method.

http://www.google.com/search?q=parse+avm2

Chemulpo answered 27/4, 2010 at 18:3 Comment(0)
E
-1

My instinct is no, ExternalInterface is essentially a black box, or black letter box, you poke things through and sometimes things come back, but you can't open the door to see what's inside.

Without documentation as to what's been exposed in the SWF, the only other suggestion is decompiling the swf to have a look at the source.

Ewens answered 15/4, 2010 at 9:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.