tuarua / WebViewANE

WebView Adobe Air Native Extension for macOS 10.10+, Windows Desktop, iOS 9.0+ and Android 19+. This ANE provides access to a more modern webview from AIR.
Apache License 2.0
183 stars 53 forks source link

Question about load() and evaluateJavascript() #175

Closed jsrdzhk closed 6 years ago

jsrdzhk commented 6 years ago

Hi, @tuarua !Thanks for watching my question.I use some code below to try to adjust the size of the viewport of WebViewANE.Here webview is the instance of WebViewANE and has been initialized by init().

webview.load(urlToLoad);
webview.evaluateJavascript("document.body.scrollWidth",onSetWebPageWidth);

private function onSetWebPageWidth(jsResult:JavascriptResult):void{
       var width:uint=jsResult as uint;
       webview.viewport=new Rectangle(50,100,width,750);
 }

However,the size of web page only adjust sometimes.I guess the evaluateJavascript() function was invoked before the whole work of load() function finished.Can you tell me what caused this situation? Or tell me another way to modify the size of webview to make its width equal to the width of html body,please.Thanks a lot!

tuarua commented 6 years ago
  1. JavascriptResult is an object. I don't know why you are casting to a uint. See the asdocs for JavascriptResult.

  2. load is asynchronous, you need to write your code taking this into consideration. As I mention in the README the issue tracker is for bugs.