Packagecom.tuarua
Classpublic class WebView
InheritanceWebView Inheritance flash.events.EventDispatcher



Public Properties
 PropertyDefined By
  currentTab : int
Windows + OSX only
WebView
  tabDetails : Vector.<TabDetails>
[read-only]
WebView
  viewPort : Rectangle
WebView
  visible : Boolean
WebView
Public Methods
 MethodDefined By
  
addCallback(functionName:String, closure:Function):void
WebView
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
[override]
WebView
  
addTab(initialUrl:URLRequest = null):void
Windows + OSX only
WebView
  
WebView
  
WebView
  
callJavascriptFunction(functionName:String, closure:Function = null, ... args):void
WebView
  
capture(onComplete:Function, cropTo:Rectangle = null):void
Captures the webView to BitmapData.
WebView
  
clearCache():void
Clears the browser cache.
WebView
  
Clears any persistent requestHeaders added to URLRequest
WebView
  
Close the Chromium dev tools Disables Inspect Element on right click on OSX On Android disconnects from chrome://inspect
WebView
  
closeTab(index:int):void
Windows + OSX only
WebView
  
Deletes all cookies
WebView
  
dispose():void
[static] Disposes the ANE
WebView
  
evaluateJavascript(code:String, closure:Function = null):void
WebView
  
focus():void
WebView
  
go(offset:int = 1):void
WebView
  
goBack():void
Navigates back.
WebView
  
goForward():void
Navigates forward.
WebView
  
init(stage:Stage, viewPort:Rectangle, initialUrl:URLRequest = null, settings:Settings = null, scaleFactor:Number = 1.0, backgroundColor:uint = 0xFFFFFFFF):void
WebView
  
injectScript(code:String = null, scriptUrl:String = null, startLine:uint = 0):void
WebView
  
load(url:URLRequest):void
WebView
  
loadFileURL(url:String, allowingReadAccessTo:String):void
WebView
  
loadHTMLString(html:String, baseUrl:URLRequest = null):void
WebView
  
print():void
Prints the webView.
WebView
  
printToPdf(savePath:String):void
WebView
  
reload():void
Reloads the current page.
WebView
  
Forces a reload of the page (i.e.
WebView
  
removeCallback(functionName:String):void
WebView
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
[override]
WebView
  
[static]
WebView
  
Shows the Chromium dev tools on Windows Enables Inspect Element on right click on OSX On Android use Chrome on connected computer and navigate to chrome://inspect
WebView
  
Stops loading the current page.
WebView
  
zoomIn():void
Zooms in
WebView
  
zoomOut():void
Zooms out
WebView
Property Detail
currentTabproperty
currentTab:int

Windows + OSX only


Implementation
    public function get currentTab():int
    public function set currentTab(value:int):void
tabDetailsproperty 
tabDetails:Vector.<TabDetails>  [read-only]


Implementation
    public function get tabDetails():Vector.<TabDetails>
viewPortproperty 
viewPort:Rectangle


Implementation
    public function get viewPort():Rectangle
    public function set viewPort(value:Rectangle):void
visibleproperty 
visible:Boolean


Implementation
    public function get visible():Boolean
    public function set visible(value:Boolean):void
Method Detail
addCallback()method
public function addCallback(functionName:String, closure:Function):void

Parameters

functionName:String — name of the function as called from Javascript
 
closure:Function — Actionscript function to call when functionName is called from Javascript Adds a callback in the webView. These should be added before .init() is called.

addEventListener()method 
override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

Parameters

type:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0)
 
useWeakReference:Boolean (default = false)

addTab()method 
public function addTab(initialUrl:URLRequest = null):void

Windows + OSX only

Parameters

initialUrl:URLRequest (default = null)

allowsMagnification()method 
public function allowsMagnification():Boolean

Returns
Boolean — Whether the page allows magnification functionality Ignored on iOS.
backForwardList()method 
public function backForwardList():BackForwardList

Returns
BackForwardList

Ignored on Windows and Android.

callJavascriptFunction()method 
public function callJavascriptFunction(functionName:String, closure:Function = null, ... args):void

Parameters

functionName:String — name of the Javascript function to call
 
closure:Function (default = null) — Actionscript function to call when Javascript functionName is called. If null then no actionscript function is called, aka a 'fire and forget' call.
 
... args — arguments to send to the Javascript function

Call a javascript function.


Example
     // Logs to the console. No result expected.
     webView.callJavascriptFunction("as_to_js",asToJsCallback,1,"a",77);
     
     public function asToJsCallback(jsResult:JavascriptResult):void {
        trace("asToJsCallback");
        trace("jsResult.error", jsResult.error);
        trace("jsResult.result", jsResult.result);
        trace("jsResult.message", jsResult.message);
        trace("jsResult.success", jsResult.success);
        var testObject:= jsResult.result;
        trace(testObject);
     }
     
     // Calls Javascript function passing 3 args. Javascript function returns an
     // object which is automatically mapped to an
     // Actionscript Object
     webView.callJavascriptFunction("console.log",null,"hello console. The is AIR");
     
     // function in HTML page
     function as_to_js(numberA, stringA, numberB, obj) {
     var person = {
         name: "Jim Cowart",
         response: {
             name: "Chattanooga",
                population: 167674
            }
        };
        return person;
     }
     
capture()method 
public function capture(onComplete:Function, cropTo:Rectangle = null):void

Captures the webView to BitmapData.

Parameters

onComplete:Function — function(result:BitmapData)
 
cropTo:Rectangle (default = null) — optionally crops to the supplied Rectangle

clearCache()method 
public function clearCache():void

Clears the browser cache. Available on iOS, OSX, Android only.

Ignored on Windows.

You cannot clear the cache on Windows while CEF is running. This is a known limitation. You can delete the contents of the value of your settings.cef.cachePath using Actionscript only before you call .init(). Calling after .dispose() may cause file locks as the files may still be 'owned' by the CEF process

clearRequestHeaders()method 
public function clearRequestHeaders():void

Clears any persistent requestHeaders added to URLRequest

closeDevTools()method 
public function closeDevTools():void

Close the Chromium dev tools

Disables Inspect Element on right click on OSX

On Android disconnects from chrome://inspect

closeTab()method 
public function closeTab(index:int):void

Windows + OSX only

Parameters

index:int

deleteCookies()method 
public function deleteCookies():void

Deletes all cookies

dispose()method 
public static function dispose():void

Disposes the ANE

evaluateJavascript()method 
public function evaluateJavascript(code:String, closure:Function = null):void

Parameters

code:String — Javascript string to evaluate.
 
closure:Function (default = null) — Actionscript function to call when the Javascript string is evaluated. If null then no actionscript function is called, aka a 'fire and forget' call.


Example
     // Set the body background to yellow. No result expected
     webView.evaluateJavascript('document.getElementsByTagName("body")[0].style.backgroundColor = "yellow";');
     
     // Retrieve contents of div. Result is returned to Actionscript function 'onJsEvaluated'
     webView.evaluateJavascript("document.getElementById('output').innerHTML;", onJsEvaluated)
     private function onJsEvaluated(jsResult:JavascriptResult):void {
        trace("innerHTML of div is:", jsResult.result);
     }
     
focus()method 
public function focus():void

go()method 
public function go(offset:int = 1):void

Parameters

offset:int (default = 1) — Navigate forward (eg +1) or back (eg -1)

goBack()method 
public function goBack():void

Navigates back.

goForward()method 
public function goForward():void

Navigates forward.

init()method 
public function init(stage:Stage, viewPort:Rectangle, initialUrl:URLRequest = null, settings:Settings = null, scaleFactor:Number = 1.0, backgroundColor:uint = 0xFFFFFFFF):void

Parameters

stage:Stage
 
viewPort:Rectangle
 
initialUrl:URLRequest (default = null) — Url to load when the view loads
 
settings:Settings (default = null)
 
scaleFactor:Number (default = 1.0) — iOS, Android only
 
backgroundColor:uint (default = 0xFFFFFFFF) — value of the view's background color in ARGB format.

Initialises the webView. N.B. The webView is set to visible = false initially.

injectScript()method 
public function injectScript(code:String = null, scriptUrl:String = null, startLine:uint = 0):void

Parameters

code:String (default = null) — Javascript to inject, if any.
 
scriptUrl:String (default = null) — is the URL where the script in question can be found, if any. Windows only
 
startLine:uint (default = 0) — is the base line number to use for error reporting. Windows only

Specify either code or scriptUrl. These are injected into the main Frame when it is loaded. Call before load() method

Ignored on Android.

load()method 
public function load(url:URLRequest):void

Parameters

url:URLRequest

loadFileURL()method 
public function loadFileURL(url:String, allowingReadAccessTo:String):void

Parameters

url:String — full path to the file on the local file system
 
allowingReadAccessTo:String — path to the root of the document Loads a file from the local file system into the webView.

loadHTMLString()method 
public function loadHTMLString(html:String, baseUrl:URLRequest = null):void

Parameters

html:String — HTML provided as a string
 
baseUrl:URLRequest (default = null) — url which will display as the address Loads a HTML string into the webView.

print()method 
public function print():void

Prints the webView.

Windows and macOS 11.0+ only.

printToPdf()method 
public function printToPdf(savePath:String):void

Parameters

savePath:String — path to save the pdf to. Prints the webView to a pdf.

Windows and macOS 11.0+ only.

reload()method 
public function reload():void

Reloads the current page.

reloadFromOrigin()method 
public function reloadFromOrigin():void

Forces a reload of the page (i.e. ctrl F5)

removeCallback()method 
public function removeCallback(functionName:String):void

Parameters

functionName:String — name of the function to remove. This function should have been added via .addCallback() method

removeEventListener()method 
override public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void

Parameters

type:String
 
listener:Function
 
useCapture:Boolean (default = false)

shared()method 
public static function shared():WebView

Returns
WebView
showDevTools()method 
public function showDevTools():void

Shows the Chromium dev tools on Windows

Enables Inspect Element on right click on OSX

On Android use Chrome on connected computer and navigate to chrome://inspect

stopLoading()method 
public function stopLoading():void

Stops loading the current page.

zoomIn()method 
public function zoomIn():void

Zooms in

zoomOut()method 
public function zoomOut():void

Zooms out