Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get ExternalInterface definitions in Javascript

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.

like image 613
Jamal Fanaian Avatar asked Jan 12 '10 21:01

Jamal Fanaian


3 Answers

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.

like image 123
Tobias Avatar answered Nov 01 '22 20:11

Tobias


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.

like image 21
newtover Avatar answered Nov 01 '22 20:11

newtover


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.

like image 30
Abhinav Avatar answered Nov 01 '22 22:11

Abhinav