| Package | com.myflashlab.air.extensions.webView |
| Class | public class RichWebView |
| Inheritance | RichWebView flash.events.EventDispatcher |
Deprecated! use com.myflashlab.air.extensions.richWebView.RichWebView instead.
Download .ane from: http://www.myflashlabs.com/product/rich-webview-ane-adobe-air-native-extension/
Make sure to take care of the permissions manually if you are targeting AIR SDK 24+: https://github.com/myflashlab/webView-ANE/#permissions
See also
| Property | Defined By | ||
|---|---|---|---|
| canGoBack : Boolean [read-only]
returns true if webView can go back in history
| RichWebView | ||
| canGoForward : Boolean [read-only]
returns true if webView can go forward in history
| RichWebView | ||
| contentHeight : int [read-only]
indicates the content height of your HTML content
| RichWebView | ||
| height : int
Indicates the height of the rich webview relative to the main stage
| RichWebView | ||
| isEmbeddedBrowserInitialized : Boolean [read-only] | RichWebView | ||
| maximumZoomScale : Number
iOS Only - indicates the maximumZoomScale
| RichWebView | ||
| minimumZoomScale : Number
iOS Only - indicates the minimumZoomScale
| RichWebView | ||
| os : String [read-only]
indicates the current OS which the app is running in. | RichWebView | ||
| scrollX : int [read-only]
indicates the x position for the scroller
| RichWebView | ||
| scrollY : int [read-only]
indicates the y position for the scroller
| RichWebView | ||
| sdkVersion : int [read-only]
indicates the Android SDK version. | RichWebView | ||
| visible : Boolean [write-only]
change the visibility of the webview.
On Android, when the webview is present, it will hijack the device's back button. | RichWebView | ||
| width : int
Indicates the width of the rich webview relative to the main stage
| RichWebView | ||
| x : int
Indicates the x position of the rich webview relative to the main stage
| RichWebView | ||
| y : int
Indicates the y position of the rich webview relative to the main stage
| RichWebView | ||
| zoomScale : Number
iOS Only - indicates the zoomScale for the wevView
| RichWebView | ||
| Method | Defined By | ||
|---|---|---|---|
RichWebView($stage:Stage = null)
Initialize the extension and pass in the flash stage to it so it can calculate the correct dimensions for the webView rectangle. | RichWebView | ||
addEventListener($type:String, $listener:Function, $useCapture:Boolean = false, $priority:int = 0, $useWeakReference:Boolean = false):void [override]
| RichWebView | ||
callJS($msg:String):void
use this method to call Javascript functions. | RichWebView | ||
clearCache($bool:Boolean):void
Android only - clears browsing cache. | RichWebView | ||
clearHistory():void
Android only - clears history
| RichWebView | ||
closeWebView():void
Use this method to close the webView window. | RichWebView | ||
dispose():void
to dispose the extension
| RichWebView | ||
disposeEmbeddedBrowser():void | RichWebView | ||
filingScroll($x:int, $y:int):void
Animate the scroller to the specified x,y location. | RichWebView | ||
goBack():void
if _ex.canGoBack is true, it will take the webview one page back
| RichWebView | ||
goForward():void
if _ex.canGoForward is true, it will take the webview one page forward
| RichWebView | ||
hide($value:Boolean):void
Hide the webview instance so it's not visible anymore. | RichWebView | ||
initEmbeddedBrowser():void | RichWebView | ||
isEmbeddedBrowserSupported():Boolean | RichWebView | ||
isSupported():Boolean
indicates if the extension is supported on the running device or not. | RichWebView | ||
moveAndroidTaskToBack():Boolean
Move the Air application to the back of the activity stack which will result in showing the Android's home menu. | RichWebView | ||
openData($x:int, $y:int, $width:int, $height:int, $data:HtmlDataSettings):void | RichWebView | ||
openEmbeddedBrowser($url:String):Boolean | RichWebView | ||
openWebViewLocal($x:int, $y:int, $width:int, $height:int, $file:File):void
Use this method to open local html files on sdcard. | RichWebView | ||
openWebViewURL($x:int, $y:int, $width:int, $height:int, $url:String):void
Use this method for loading online URLs
| RichWebView | ||
pageDown($bool:Boolean):Boolean
Call this method to move the scrollbar down. | RichWebView | ||
pageUp($bool:Boolean):Boolean
Call this method to move the scrollbar up. | RichWebView | ||
pauseTimers():void
Android only - when going to background, call this method to save resources on your device. | RichWebView | ||
reload():void
reloads the page. | RichWebView | ||
removeEventListener($type:String, $listener:Function, $useCapture:Boolean = false):void [override]
| RichWebView | ||
requestBitmap():void
Call this method to request the extension for a screenshot of the whole webview. | RichWebView | ||
resumeTimers():void
Android only - if you had called pauseTimers() before going to background, you should call this method to reactivate your HTML content. | RichWebView | ||
scrollBy($x:int, $y:int):void
move the scroller by the x,y amount
| RichWebView | ||
scrollTo($x:int, $y:int):void
move the scroller to the specified x,y location
| RichWebView | ||
setPosition($x:int, $y:int, $width:int, $height:int):void | RichWebView | ||
setViewPort($rect:Rectangle):void
Use this method to resize and reposition the webView viewport at runtime. | RichWebView | ||
shouldContinueLoadingTheURL():void
Call this method only in RichWebViewEvent.PAGE_STARTING event to allow the process
of loading the url
| RichWebView | ||
stopLoad():void
Call this method to stop loading the current page
| RichWebView | ||
zoomIn():Boolean
Use this method to zoom in to your HTML page. | RichWebView | ||
zoomOut():Boolean
Use this method to zoom out from your HTML page. | RichWebView | ||
| Constant | Defined By | ||
|---|---|---|---|
| ANDROID : String = android [static] | RichWebView | ||
| EXTENSION_ID : String = com.myflashlab.air.extensions.webView [static]
Extension ID for this extension
| RichWebView | ||
| IOS : String = ios [static] | RichWebView | ||
| VERSION : String = 9.0.0 [static]
current version number of this extension
| RichWebView | ||
| canGoBack | property |
canGoBack:Boolean [read-only] returns true if webView can go back in history
public function get canGoBack():Boolean| canGoForward | property |
canGoForward:Boolean [read-only] returns true if webView can go forward in history
public function get canGoForward():Boolean| contentHeight | property |
contentHeight:int [read-only] indicates the content height of your HTML content
public function get contentHeight():int| height | property |
height:intIndicates the height of the rich webview relative to the main stage
public function get height():int public function set height(value:int):void| isEmbeddedBrowserInitialized | property |
isEmbeddedBrowserInitialized:Boolean [read-only] public function get isEmbeddedBrowserInitialized():Boolean| maximumZoomScale | property |
maximumZoomScale:NumberiOS Only - indicates the maximumZoomScale
public function get maximumZoomScale():Number public function set maximumZoomScale(value:Number):void| minimumZoomScale | property |
minimumZoomScale:NumberiOS Only - indicates the minimumZoomScale
public function get minimumZoomScale():Number public function set minimumZoomScale(value:Number):void| os | property |
os:String [read-only] indicates the current OS which the app is running in. it's either MyAR.ANDROID or MyAR.IOS
public function get os():String| scrollX | property |
scrollX:int [read-only] indicates the x position for the scroller
public function get scrollX():int| scrollY | property |
scrollY:int [read-only] indicates the y position for the scroller
public function get scrollY():int| sdkVersion | property |
sdkVersion:int [read-only] indicates the Android SDK version. you will need this when you are writting your JS logic when dealing with FileSelect input fields. You should check if current device is running on Lollipop Android or above and make sure your JS matches that. Depending on your tasks, you may need to write your JS differently, so, make sure to search the web to be able to safely get the desired outcome on all Android versions.
public function get sdkVersion():int| visible | property |
visible:Boolean [write-only]
change the visibility of the webview.
On Android, when the webview is present, it will hijack the device's back button. and you should listen to the RichWebViewEvent.BACK_CLICKED
event to know when the device's back button is clicked. The same thing still happens when you're hidding the webview using this property or the
hide() method.
In simple words, even if you are hidding the webview, it's still there and it's still hijacking the device's back button.
public function set visible(value:Boolean):voidSee also
| width | property |
width:intIndicates the width of the rich webview relative to the main stage
public function get width():int public function set width(value:int):void| x | property |
x:intIndicates the x position of the rich webview relative to the main stage
public function get x():int public function set x(value:int):void| y | property |
y:intIndicates the y position of the rich webview relative to the main stage
public function get y():int public function set y(value:int):void| zoomScale | property |
zoomScale:NumberiOS Only - indicates the zoomScale for the wevView
public function get zoomScale():Number public function set zoomScale(value:Number):void| RichWebView | () | Constructor |
public function RichWebView($stage:Stage = null)
Initialize the extension and pass in the flash stage to it so it can calculate the correct dimensions for the webView rectangle.
the other settings in the constructor are now deprecated and you should use the RichWebViewSettings class to set the
required settings for your RichWebView instance.
$stage:Stage (default = null) |
See also
| 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) |
| callJS | () | method |
public function callJS($msg:String):voiduse this method to call Javascript functions. for example if you have a function in your js like this:
function diplayAlert(msg)
{
alert(msg);
}
you can call it this way:
_ex.callJS("diplayAlert('a msg from flash!')");
Parameters
$msg:String |
| clearCache | () | method |
public function clearCache($bool:Boolean):voidAndroid only - clears browsing cache.
Parameters
$bool:Boolean |
| clearHistory | () | method |
public function clearHistory():voidAndroid only - clears history
| closeWebView | () | method |
public function closeWebView():voidUse this method to close the webView window.
| dispose | () | method |
public function dispose():voidto dispose the extension
| disposeEmbeddedBrowser | () | method |
public function disposeEmbeddedBrowser():void| filingScroll | () | method |
public function filingScroll($x:int, $y:int):voidAnimate the scroller to the specified x,y location.
Parameters
$x:int | |
$y:int |
See also
| goBack | () | method |
public function goBack():voidif
_ex.canGoBackis true, it will take the webview one page back
| goForward | () | method |
public function goForward():voidif
_ex.canGoForwardis true, it will take the webview one page forward
| hide | () | method |
public function hide($value:Boolean):void
Hide the webview instance so it's not visible anymore. you can make it visible again by passing false to this method.
On Android, when the webview is present, it will hijack the device's back button. and you should listen to the RichWebViewEvent.BACK_CLICKED
event to know when the device's back button is clicked. The same thing still happens when you're hidding the webview using this method or the
visible setter property.
In simple words, even if you are hidding the webview, it's still there and it's still hijacking the device's back button.
Parameters
$value:Boolean — visiblility value of the RichWebView
|
See also
| initEmbeddedBrowser | () | method |
public function initEmbeddedBrowser():void| isEmbeddedBrowserSupported | () | method |
public function isEmbeddedBrowserSupported():BooleanReturnsBoolean |
| isSupported | () | method |
public function isSupported():Booleanindicates if the extension is supported on the running device or not. in iOS, the min SDK Version is 6.1
ReturnsBoolean — |
| moveAndroidTaskToBack | () | method |
public function moveAndroidTaskToBack():BooleanMove the Air application to the back of the activity stack which will result in showing the Android's home menu.
ReturnsBoolean — If the task was moved (or it was already at the back) true is returned, else false.
|
| openData | () | method |
public function openData($x:int, $y:int, $width:int, $height:int, $data:HtmlDataSettings):voidParameters
$x:int | |
$y:int | |
$width:int | |
$height:int | |
$data:HtmlDataSettings |
| openEmbeddedBrowser | () | method |
public function openEmbeddedBrowser($url:String):BooleanParameters
$url:String |
Boolean |
| openWebViewLocal | () | method |
public function openWebViewLocal($x:int, $y:int, $width:int, $height:int, $file:File):voidUse this method to open local html files on sdcard.
Parameters
$x:int | |
$y:int | |
$width:int | |
$height:int | |
$file:File |
| openWebViewURL | () | method |
public function openWebViewURL($x:int, $y:int, $width:int, $height:int, $url:String):voidUse this method for loading online URLs
Parameters
$x:int | |
$y:int | |
$width:int | |
$height:int | |
$url:String |
| pageDown | () | method |
public function pageDown($bool:Boolean):BooleanCall this method to move the scrollbar down. pass
trueand the page will go the whole way down otherwise it will go down only to the hight of the current view.
Parameters
$bool:Boolean |
Boolean — |
| pageUp | () | method |
public function pageUp($bool:Boolean):BooleanCall this method to move the scrollbar up. pass
trueand the page will go the whole way up otherwise it will go up only to the hight of the current view.
Parameters
$bool:Boolean |
Boolean — |
| pauseTimers | () | method |
public function pauseTimers():voidAndroid only - when going to background, call this method to save resources on your device. it will pause all html5 processes or animation or timers.
See also
| reload | () | method |
public function reload():voidreloads the page.
| removeEventListener | () | method |
override public function removeEventListener($type:String, $listener:Function, $useCapture:Boolean = false):void
Parameters
$type:String | |
$listener:Function | |
$useCapture:Boolean (default = false) |
| requestBitmap | () | method |
public function requestBitmap():void
Call this method to request the extension for a screenshot of the whole webview. when the screenshot is ready,
RichWebViewEvent.SCREENSHOT will be dispatched and you can access the BitmapData object in e.param
| resumeTimers | () | method |
public function resumeTimers():voidAndroid only - if you had called pauseTimers() before going to background, you should call this method to reactivate your HTML content.
See also
| scrollBy | () | method |
public function scrollBy($x:int, $y:int):voidmove the scroller by the x,y amount
Parameters
$x:int | |
$y:int |
| scrollTo | () | method |
public function scrollTo($x:int, $y:int):voidmove the scroller to the specified x,y location
Parameters
$x:int | |
$y:int |
See also
| setPosition | () | method |
public function setPosition($x:int, $y:int, $width:int, $height:int):void
Parameters
$x:int | |
$y:int | |
$width:int | |
$height:int |
See also
| setViewPort | () | method |
public function setViewPort($rect:Rectangle):voidUse this method to resize and reposition the webView viewport at runtime. Or you can use the x, y, width and height properties individually. but using this method to set all the properties in one call will be a bit more CPU friendly.
Parameters
$rect:Rectangle |
| shouldContinueLoadingTheURL | () | method |
public function shouldContinueLoadingTheURL():void
Call this method only in RichWebViewEvent.PAGE_STARTING event to allow the process
of loading the url
| stopLoad | () | method |
public function stopLoad():voidCall this method to stop loading the current page
| zoomIn | () | method |
public function zoomIn():BooleanUse this method to zoom in to your HTML page. on iOS, you may need to set
maximumZoomScaleand
minimumZoomScalebefore trying to zoom. Returns
Boolean — |
| zoomOut | () | method |
public function zoomOut():BooleanUse this method to zoom out from your HTML page. on iOS, you may need to set
maximumZoomScaleand
minimumZoomScalebefore trying to zoom. Returns
Boolean — |
| ANDROID | Constant |
public static const ANDROID:String = android| EXTENSION_ID | Constant |
public static const EXTENSION_ID:String = com.myflashlab.air.extensions.webViewExtension ID for this extension
| IOS | Constant |
public static const IOS:String = ios| VERSION | Constant |
public static const VERSION:String = 9.0.0current version number of this extension
import com.myflashlab.air.extensions.webView.
var _ex:RichWebView = new RichWebView(this.stage);
// indicates the Android SDK version. you will need this when you are writting your JS logic when dealing with FileSelect input fields.
trace("Android SDK version: ", _ex.sdkVersion);
// add listeners
_ex.addEventListener(RichWebViewEvent.BACK_CLICKED, onBackClicked);
_ex.addEventListener(RichWebViewEvent.PAGE_STARTED, onPageStarted);
_ex.addEventListener(RichWebViewEvent.PAGE_PROGRESS, onPageProgress);
_ex.addEventListener(RichWebViewEvent.PAGE_FINISHED, onPageFinished);
_ex.addEventListener(RichWebViewEvent.RECEIVED_SSL_ERROR, onReceivedError);
_ex.addEventListener(RichWebViewEvent.RECEIVED_MESSAGE_FROM_JS, onReceivedMessage);
_ex.addEventListener(RichWebViewEvent.SCREENSHOT, onScreenshot);
_ex.addEventListener(RichWebViewEvent.TOUCH, onTouch);
// set optional RichWebview settings (apply these settings AFTER initializing the ANE and BEFORE opening a webpage)
RichWebViewSettings.ENABLE_BITMAP_CAPTURE = true;
RichWebViewSettings.ENABLE_COOKIES = true;
RichWebViewSettings.ENABLE_THIRD_PARTY_COOKIES = true;
RichWebViewSettings.ENABLE_GPS = true;
RichWebViewSettings.ENABLE_ZOOM = true;
RichWebViewSettings.ENABLE_SCROLL_BOUNCE = false;
RichWebViewSettings.BG_COLOR_HEX = "#FFFFFFFF"; // AARRGGBB
//RichWebViewSettings.USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.36 (KHTML, like Gecko) Chrome/13.0.766.0 Safari/534.36"; // useful when you are trying to load embedded YouTube or Vimeo videos
RichWebViewSettings.ENABLE_AIR_PREFIX = true; // This property works on Android ONLY and is set to true by default.
RichWebViewSettings.MEDIA_PLAYBACK_REQUIRES_USER_GESTURE = true;
// you may load local html content from File.documentsDirectory or File.applicationStorageDirectory
_ex.openWebViewLocal(0, 0, stage.stageWidth, stage.stageHeight, File.documentsDirectory.resolvePath("webview/index.html"));
// or you may load an online url as follow
//_ex.openWebViewURL(0, 0, stage.stageWidth, stage.stageHeight, "http://www.myflashlabs.com/");
function onBackClicked(e:RichWebViewEvent):void
{
if (_ex.canGoBack) _ex.goBack();
else _ex.closeWebView();
}
function onPageStarted(e:RichWebViewEvent):void
{
trace("page started to be loaded");
}
function onPageProgress(e:RichWebViewEvent):void
{
trace("page loading: " + e.param + "%");
}
function onPageFinished(e:RichWebViewEvent):void
{
trace("page load completed");
}
function onReceivedError(e:RichWebViewEvent):void
{
trace("error = " + e.param);
}
function onReceivedMessage(e:RichWebViewEvent):void
{
trace("onReceivedMessage: ", e.param);
}
function onScreenshot(e:RichWebViewEvent):void
{
var bm:Bitmap = new Bitmap(e.param, "auto", true);
this.addChild(bm);
}
function onTouch(e:RichWebViewEvent):void
{
trace("onTouch > " + "x = " + e.param.x + " y = " + e.param.y);
}