Packagecom.distriqt.extension.nativewebview
Interfacepublic interface WebView extends flash.events.IEventDispatcher

This describes the interface to a Web View created by a call to NativeWebView.service.createWebView

See also

com.distriqt.extension.nativewebview.NativeWebView.createWebView()


Public Properties
 PropertyDefined By
  canGoBack : Boolean
[read-only] Whether there is a previous page in the browsing history.
WebView
  canGoForward : Boolean
[read-only] Whether there is a next page in the browsing history.
WebView
  cookies : Object
[read-only]
WebView
  height : int
The height of the web view
WebView
  htmlSource : String
[read-only] The HTML source of the current page
WebView
  isHistoryBackEnabled : Boolean
[read-only]
WebView
  isHistoryForwardEnabled : Boolean
[read-only]
WebView
  isPrintSupported : Boolean
[read-only] If true then printing is supported of the current webview.
WebView
  location : String
[read-only] The URL of the current location
WebView
  statusCode : int
[read-only] The HTML status code of the loaded page
WebView
  title : String
[read-only] The HTML title value
WebView
  userAgent : String
The user agent that loaded the current page
WebView
  viewPort : Rectangle
Set the view port of the webview in native coordinates
WebView
  visible : Boolean
Controls whether the view is currently visible.
WebView
  width : int
The width of the web view
WebView
  x : int
The x position of the web view
WebView
  y : int
The y position of the web view
WebView
Public Methods
 MethodDefined By
  
clearCache():Boolean
Attempts to clear any cached data
WebView
  
dispose():void
Clears and removes the WebView from the stage, stopping any load operations.
WebView
  
drawViewPortToBitmapData(bitmapData:BitmapData, callback:Function = null):void
Draws the WebView's view port to a bitmap.
WebView
  
evaluateJavascript(script:String):String
Returns the result of running the script.
WebView
  
Navigates to the previous page in the browsing history
WebView
  
Navigates to the next page in the browsing history
WebView
  
loadString(text:String, mimeType:String = text/html, baseUrl:String):void
Loads and displays the specified HTML string.
WebView
  
loadURL(url:String, additionalHeaders:Vector.<Header> = null):void
Loads the page at the specified URL.
WebView
  
pageDown(animated:Boolean = true):void
Moves the view down by one page (viewport height)
WebView
  
pageUp(animated:Boolean = true):void
Moves the view up by one page (viewport height)
WebView
  
print(options:PrintOptions):void
Displays the printing options for the current page.
WebView
  
reload():void
Reloads the current page
WebView
  
scrollBy(x:Number, y:Number, animated:Boolean = true):void
Moves the displayed view by the specified amount
WebView
  
scrollTo(x:Number, y:Number, animated:Boolean = true):void
Moves the displayed view to the specified position
WebView
  
setFocus(focused:Boolean):void
Android only
WebView
  
stop():void
Halts the current load operation.
WebView
Events
 Event Summary Defined By
   Signals that the last load operation has completed WebView
   Signals that an error has occurred WebView
   This event is dispatched when a script running in the web page sends a message using the AirBridge.WebView
   A response from evaluation of javascript on the current page.WebView
   Dispatched when a target _blank link was clicked and the webview has a linkTargetAction set to block.WebView
   Signals that the location property of the WebView object has changed.WebView
   Signals that the location property of the WebView object is about to change.WebView
  WebView
Property Detail
canGoBackproperty
canGoBack:Boolean  [read-only]

Whether there is a previous page in the browsing history.

If true the historyBack operation can be performed successfully.


Implementation
    public function get canGoBack():Boolean
canGoForwardproperty 
canGoForward:Boolean  [read-only]

Whether there is a next page in the browsing history.

If true the historyForward operation can be performed successfully.


Implementation
    public function get canGoForward():Boolean
cookiesproperty 
cookies:Object  [read-only]


Implementation
    public function get cookies():Object
heightproperty 
height:int

The height of the web view


Implementation
    public function get height():int
    public function set height(value:int):void
htmlSourceproperty 
htmlSource:String  [read-only]

The HTML source of the current page


Implementation
    public function get htmlSource():String
isHistoryBackEnabledproperty 
isHistoryBackEnabled:Boolean  [read-only]


Implementation
    public function get isHistoryBackEnabled():Boolean

See also

canGoBack()
isHistoryForwardEnabledproperty 
isHistoryForwardEnabled:Boolean  [read-only]


Implementation
    public function get isHistoryForwardEnabled():Boolean

See also

canGoForward()
isPrintSupportedproperty 
isPrintSupported:Boolean  [read-only]

If true then printing is supported of the current webview.


Implementation
    public function get isPrintSupported():Boolean
locationproperty 
location:String  [read-only]

The URL of the current location


Implementation
    public function get location():String
statusCodeproperty 
statusCode:int  [read-only]

The HTML status code of the loaded page


Implementation
    public function get statusCode():int
titleproperty 
title:String  [read-only]

The HTML title value


Implementation
    public function get title():String
userAgentproperty 
userAgent:String

The user agent that loaded the current page


Implementation
    public function get userAgent():String
    public function set userAgent(value:String):void
viewPortproperty 
viewPort:Rectangle

Set the view port of the webview in native coordinates


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

Controls whether the view is currently visible. Setting this to false will remove the view from your application but still keep it active in the background.


Implementation
    public function get visible():Boolean
    public function set visible(value:Boolean):void
widthproperty 
width:int

The width of the web view


Implementation
    public function get width():int
    public function set width(value:int):void
xproperty 
x:int

The x position of the web view


Implementation
    public function get x():int
    public function set x(value:int):void
yproperty 
y:int

The y position of the web view


Implementation
    public function get y():int
    public function set y(value:int):void
Method Detail
clearCache()method
public function clearCache():Boolean

Attempts to clear any cached data

Returns
Boolean
dispose()method 
public function dispose():void

Clears and removes the WebView from the stage, stopping any load operations.

After this call the web view will be in an invalid state and any subsequent calls will have undefined results. You should remove all event listeners before calling this and set your reference to null afterwards.


Example
         webView.removeEventListener( NativeWebViewEvent.LOCATION_CHANGING, webView_locationChangingHandler );
         webView.removeEventListener( NativeWebViewEvent.LOCATION_CHANGE, webView_locationChangeHandler );
         webView.removeEventListener( NativeWebViewEvent.COMPLETE, webView_completeHandler );
         webView.removeEventListener( NativeWebViewEvent.ERROR, webView_errorHandler );
         webView.removeEventListener( NativeWebViewEvent.JAVASCRIPT_RESPONSE, webView_javascriptResponseHandler );
         webView.dispose();
         webView = null;
         
drawViewPortToBitmapData()method 
public function drawViewPortToBitmapData(bitmapData:BitmapData, callback:Function = null):void

Draws the WebView's view port to a bitmap.

Capture the bitmap and set the stage to null for displaying the content above the StageWebView object.

Note: The behavior of this method is not guaranteed for pages that contain plugin content (such as embedded PDF and SWF files).

This process is not synchronous. The bitmap data object may be rendered at a point after the execution of this function. Hence you should not use the bitmap data until either the callback function has been called or the NativeWebViewEvent.DRAWVIEWPORT_COMPLETE event has been dispatched.

Parameters

bitmapData:BitmapData — The BitmapData object on which to draw the visible portion of the WebView's view port
 
callback:Function (default = null) — Callback function executed when the bitmap data has been rendered

evaluateJavascript()method 
public function evaluateJavascript(script:String):String

Returns the result of running the script.

This function will dispatch an event that contains the response from the evaluation of the Javascript.

Parameters

script:String — A JavaScript string to run

Returns
String

See also

historyBack()method 
public function historyBack():void

Navigates to the previous page in the browsing history

historyForward()method 
public function historyForward():void

Navigates to the next page in the browsing history

loadString()method 
public function loadString(text:String, mimeType:String = text/html, baseUrl:String):void

Loads and displays the specified HTML string.

When the loadString() method is used, the location is reported as "about:blank". Only standard URI schemes can be used in URLs within the HTML string. The AIR URI schemes, "app:" and "app-storage:" are not allowed.

The HTML content cannot load local resources, such as image files. XMLHttpRequests are not allowed.

Only the "text/html" and "application/xhtml+xml" MIME types are supported.

Parameters

text:String — The string of HTML or XHTML content to display
 
mimeType:String (default = text/html) — The MIME type of the content, either "text/html" or "application/xhtml+xml"
 
baseUrl:String
  • Android: The base path or url to pass to this html. This allows loading of resources relative to this url. Eg if you have assets you wish to load in File.applicationStorageDirectory then use "file://" + File.applicationStorageDirectory.nativePath + "/"
  • iOS: The path is always relative to the packaged assets root and this variable is ignored

loadURL()method 
public function loadURL(url:String, additionalHeaders:Vector.<Header> = null):void

Loads the page at the specified URL.

The URL can use the following URI schemes: http:, https:, file:, data:, javascript: Content loaded with the file: scheme can load other local resources.

Parameters

url:String
 
additionalHeaders:Vector.<Header> (default = null)

pageDown()method 
public function pageDown(animated:Boolean = true):void

Moves the view down by one page (viewport height)

Parameters

animated:Boolean (default = true)

pageUp()method 
public function pageUp(animated:Boolean = true):void

Moves the view up by one page (viewport height)

Parameters

animated:Boolean (default = true)

print()method 
public function print(options:PrintOptions):void

Displays the printing options for the current page.

iOS only

Parameters

options:PrintOptions — Display options for the printing options dialog

reload()method 
public function reload():void

Reloads the current page

scrollBy()method 
public function scrollBy(x:Number, y:Number, animated:Boolean = true):void

Moves the displayed view by the specified amount

Parameters

x:Number
 
y:Number
 
animated:Boolean (default = true)

scrollTo()method 
public function scrollTo(x:Number, y:Number, animated:Boolean = true):void

Moves the displayed view to the specified position

Parameters

x:Number
 
y:Number
 
animated:Boolean (default = true)

setFocus()method 
public function setFocus(focused:Boolean):void

Android only

Parameters

focused:Boolean

stop()method 
public function stop():void

Halts the current load operation.

Event Detail
complete Event
Event Object Type: com.distriqt.extension.nativewebview.events.NativeWebViewEvent
NativeWebViewEvent.type property = com.distriqt.extension.nativewebview.events.NativeWebViewEvent.COMPLETE

Signals that the last load operation has completed
error Event  
Event Object Type: com.distriqt.extension.nativewebview.events.NativeWebViewEvent
NativeWebViewEvent.type property = com.distriqt.extension.nativewebview.events.NativeWebViewEvent.ERROR

Signals that an error has occurred
javascriptMessage Event  
Event Object Type: com.distriqt.extension.nativewebview.events.NativeWebViewEvent
NativeWebViewEvent.type property = com.distriqt.extension.nativewebview.events.NativeWebViewEvent.JAVASCRIPT_MESSAGE

This event is dispatched when a script running in the web page sends a message using the AirBridge. This can be used to receive communications from Javascript. data will contain the javascript message.
javascriptResponse Event  
Event Object Type: com.distriqt.extension.nativewebview.events.NativeWebViewEvent
NativeWebViewEvent.type property = com.distriqt.extension.nativewebview.events.NativeWebViewEvent.JAVASCRIPT_RESPONSE

A response from evaluation of javascript on the current page. data will contain the javascript string result.
linkBlocked Event  
Event Object Type: com.distriqt.extension.nativewebview.events.NativeWebViewEvent
NativeWebViewEvent.type property = com.distriqt.extension.nativewebview.events.NativeWebViewEvent.LINK_BLOCKED

Dispatched when a target _blank link was clicked and the webview has a linkTargetAction set to block. This gives the developer a chance to handle the url in an alternative manner.
locationChange Event  
Event Object Type: com.distriqt.extension.nativewebview.events.NativeWebViewEvent
NativeWebViewEvent.type property = com.distriqt.extension.nativewebview.events.NativeWebViewEvent.LOCATION_CHANGE

Signals that the location property of the WebView object has changed.
locationChanging Event  
Event Object Type: com.distriqt.extension.nativewebview.events.NativeWebViewEvent
NativeWebViewEvent.type property = com.distriqt.extension.nativewebview.events.NativeWebViewEvent.LOCATION_CHANGING

Signals that the location property of the WebView object is about to change. A locationChanging event is dispatched whenever the location in the web view is going to change. You can call the preventDefault() method of the event object to cancel the default behavior.
touchTap Event  
Event Object Type: flash.events.TouchEvent
TouchEvent.type property = flash.events.TouchEvent.TOUCH_TAP