I’ve ran into a odd problem when it comes to ExternalInterface.call Method. The Authoring Layer for the tool I’m developing use Chromium and I’m able to call Methods using document.getElementById(‘openfl-content’).clearSelectedItem()
that was added with ExternalInterface.addCallback. However I’m not able to call the binding/hooks put in place by me to talk to the .NET layer. Here is an example of how to add in the bindings:
public class BoundObject
{
public class AsyncBoundObject
{
//We expect an exception here, so tell VS to ignore
[DebuggerHidden]
public void Error()
{
throw new Exception("This is an exception coming from C#");
}
//We expect an exception here, so tell VS to ignore
[DebuggerHidden]
public int Div(int divident, int divisor)
{
return divident / divisor;
}
}
}
// After your ChromiumWebBrowser has been created you can register the object, if you wait too long an exception will be thrown
// saying the browser is already initialized and it’s too late.
browser = new ChromiumWebBrowser();
browser.RegisterAsyncJsObject(“boundAsync”, new AsyncBoundObject()); //Standard object rego
I’ve even checked to see if my functions where there with an JavaScript alert box and I’m able to see them can call them in the .NET layer. Just in Haxe using ExternalInterface with an HTML5 build. Anyone every ran into this problem before or got any ideas for work around?