How a mozilla extension accesses callback functions in as3?
There is a .swf file (compiled from a .as3 file) in my web page, some callback functions are defined in it:
// Security.allowDomain("*");
// ExternalInterface.addCallback("inj_click", inj_click);
// ExternalInterface.addCallback("inj_get", inj_mousedownup);
// ExternalInterface.addCallback("inj_move", inj_move);
Then I want to call it via javascript, but I met some problems:
1. Run in firefox web console, like this:
// var aa = document.getElementsByTagName('object')[0];console.dir(aa.inj_get);
It works.
2. Insert a button directly into a static html, like this:
//<script>
// function test1(){var aa = document.getElementsByTagName('object')[0];console.dir(aa.inj_get);}
//</script>
//<button onclick="test1()">test1</button>
Click button, It works.
3.Run in firefox extension, like this:
// var aa = document.getElementsByTagName('object')[0];console.dir(aa.inj_get);
It doesn't work...
4. Insert a button to the main html by a firefox extension, like this:
// var btn = document.createElement("BUTTON")
// var t = document.createTextNode("CLICK ME");
// btn.onclick = () => {var aa = document.getElementsByTagName('object')[0];console.dir(aa.inj_get);}
// btn.appendChild(t);
// document.body.appendChild(btn);
Click button, It doesn't work...
So how to solve it???
Moambuepyre
Opaite Mbohovái (4)
Web address please :
Also check your code : W3C.org (World Wide Web Consortium) in charge of standards and practices and future development of web pages and web browsers make the rules on code. Mozilla Firefox follows these rules.
HTML https://validator.w3.org/ CSS https://jigsaw.w3.org/css-validator/ and https://validator.w3.org/i18n-checker/ and http://mobile.css-validator.org/
Thank you for your response. 1. I just tested it in my local host. My real demand is to control an embedded swf (e.g. click a button) in a html. And I tried the method in Github - schellingb/SWFAutomation , he control swf via mozrepl, but I want to do that via Mozilla Extension. 2. I have deploy the instance in swftest 3. SWFAutomation/SWFAutomationPreload_Interactive.swf (compiled from SWFAutomationPreload_Interactive.as3) can be preloaded by flash_debug. 4. Then control it via extension: // var aa = document.getElementsByTagName('object')[0];console.dir(aa.inj_get);
Pkshadow said
Web address please : Also check your code : W3C.org (World Wide Web Consortium) in charge of standards and practices and future development of web pages and web browsers make the rules on code. Mozilla Firefox follows these rules. HTML https://validator.w3.org/ CSS https://jigsaw.w3.org/css-validator/ and https://validator.w3.org/i18n-checker/ and http://mobile.css-validator.org/
What messages do you see in the Browser Console related to this script? See: https://developer.mozilla.org/docs/Tools/Browser_Console
There is a forum for help with extension development, in case this is specific to those API's rather than being affected by a Firefox setting:
https://discourse.mozilla.org/c/add-ons/development
However, it's possible that plugin-controlled regions of a page are beyond the reach of standard DOM and you may need to somehow instruct the Flash plugin.
Thank u.
Yeah, maybe I should express more clearly.
I have mentioned 4 cases which works or doesn't. I used console.dir(aa.inj_get) in order to show the phenomenon: works —— console.dir lists the attribute of function inj_get in Browser_Console; doesn't —— console.dir lists a blank(i.e. can not find function inj_get)
Maybe I know little about Flash, but I think it also has to do with extensions.
jscher2000 said
What messages do you see in the Browser Console related to this script? See: https://developer.mozilla.org/docs/Tools/Browser_Console There is a forum for help with extension development, in case this is specific to those API's rather than being affected by a Firefox setting: https://discourse.mozilla.org/c/add-ons/development However, it's possible that plugin-controlled regions of a page are beyond the reach of standard DOM and you may need to somehow instruct the Flash plugin.
Moambuepyre