C# - How to PostMessage to a flash window embedded in a WebBrowser?

后端 未结 4 959
误落风尘
误落风尘 2020-12-18 09:20

I would like to know if there was any way to lock onto a Flash window and post a message to it? Another person here had the answer to it, his name is Spencer K. His question

4条回答
  •  长情又很酷
    2020-12-18 09:37

    You can do it via javascript.

    Import this:

    import flash.external.ExternalInterface;
    

    Ad this to your AS code:

    if (ExternalInterface.available) {
       // add external interface
       ExternalInterface.addCallback("jsFunction", asFunction);
    }
    
    public static function asFunction(message:String):void {
    }
    

    On your JS object of the flash object you can call this function:

    jsObject.jsFunction("message");
    

    This is the function to get the js object of the flash object:

    var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
    jsObject = InternetExplorer ? window.jsObjectName: window.document.jsObjectName;
    

    I did not test this code, I just copied it out of a project.

    edit: added js function to get js object

提交回复
热议问题