Highlighted

StageWebView gives "ReferenceError"

Community Beginner ,
Dec 01, 2016

Copy link to clipboard

Copied

I've noticed in the trace window that I sometimes get the messge

ReferenceError: Can't find variable: setProgress

When I call

_webView.loadURL("javascript:setProgress('" + theLocation + "');");

where _webView is an active StageWebView inside my AIR application (running on Windows) - (AIR v23 - but seems to happen with all AIR versions)

This error does not seem to trigger the Error event handler that I setup

  

_webView.addEventListener(ErrorEvent.ERROR, webViewError);

As this also logs the date and time that the error occurs e.g.

private function webViewError(evt:ErrorEvent)

{

        Main.log("Error: Webview - "+evt.toString());

}

StageWebView - Adobe ActionScript® 3 (AS3 ) API Reference

So I have no way to handle it.

I've tracked down when it occurs to being when load.URL is called while a page still has pending load items including ajax

Is there a event handler I can attach so that these errors can call a my error handler callback ?

TOPICS
Development

Views

324

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

StageWebView gives "ReferenceError"

Community Beginner ,
Dec 01, 2016

Copy link to clipboard

Copied

I've noticed in the trace window that I sometimes get the messge

ReferenceError: Can't find variable: setProgress

When I call

_webView.loadURL("javascript:setProgress('" + theLocation + "');");

where _webView is an active StageWebView inside my AIR application (running on Windows) - (AIR v23 - but seems to happen with all AIR versions)

This error does not seem to trigger the Error event handler that I setup

  

_webView.addEventListener(ErrorEvent.ERROR, webViewError);

As this also logs the date and time that the error occurs e.g.

private function webViewError(evt:ErrorEvent)

{

        Main.log("Error: Webview - "+evt.toString());

}

StageWebView - Adobe ActionScript® 3 (AS3 ) API Reference

So I have no way to handle it.

I've tracked down when it occurs to being when load.URL is called while a page still has pending load items including ajax

Is there a event handler I can attach so that these errors can call a my error handler callback ?

TOPICS
Development

Views

325

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 01, 2016 0
Engaged ,
Dec 02, 2016

Copy link to clipboard

Copied

For the ReferenceError you are seeing in the trace window, best guess is the page you have loaded up in the StageWebView doesn't have that function created yet when you make that call.

As to the error catcher not working, if you look at the loadURL() method, it does not throw any errors according to the documentation. The only things that throw errors are the "viewport" property when assigning it an invalid Rectangle and the "drawViewPortToBitmapData()" method.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 02, 2016 0
Community Beginner ,
Dec 02, 2016

Copy link to clipboard

Copied

@wadedwalker

Thanks for the reply..

The setProgress function does exist on the page, as js file which contains the function is already loaded and is running as I can see the code making requests to a web server.

What seems to be happening is that I can't use loadURL to call a Javascript function, using the ""javascript:FUNCTION_NAME()" method while the page is actively running any JS code.

I tried adding a COMPLETE callback, and prevented the setProgress() function being called before the complete callback had been called, and this seems to partially resolve the problem, but if I stress tested it, by repeatedly clicking on a button on the stage (which runs the code that calls setProgress(), I can still occasionally get it to give that message in the trace window.

Re:Error callback.

I think I did have some other errors which caused it to be triggered but I can't remember what those were.

The problem with the current situation, is that that I can't guarantee that the setProgress call will get run on the page.

I have a workaround because the setProgress makes an ajax post request to a server, and the server is running inside flash, so I can tell when the ajax data has been sent.

But I have an additional issue in that the time taken for the web page to send the ajax data seems to be highly variable.

Normally,  the data gets sent in less than 100mS, however believe it or not... If I leave the exe running with no input for 5 mins, then come back and press the button to trigger the process.

The internal web server in the application does not receive the data for over 1 second.

I have never seen this exceed 2 seconds, so I currently start a timer with timeout 2 seconds, when I call setProgress and if the web server has not received the data in 2 sec, have to go into a rather involved error handling process of checking if the web server is functioning or if the stageweb view is functioning.

It would be much better if flash just trigger an error when setProgess could not be run, so it could be handled in a logical way

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 02, 2016 0