MOBILE

Developing BlackBerry Tablet Applications : OS Interactions - StageWebView

12/27/2013 2:50:01 AM

The StageWebView allows for web (HTML and Flash, on supported devices) and video content to be loaded into a Flex application. StageWebView will utilize the native browser to load HTML into your application.

Let’s review the following code. First, you will notice that there is a private variable named stageWebView declared of type flash.media.StageWebView. Within applicationComplete of the application, an event handler function is called, which first checks to see if the device supports StageWebView by reading the static property of the StageWebView class. If this property returns as true, a new instance of StageWebView is created and a new Rectangle is created, sized to fill the remaining screen and set to the viewport property of the stageWebView.

There is a TextInput component with the ID of urlAddress—which holds the address that will be shown in the StageWebView—and a Button with the label “GO.”

Clicking on the GO button will call the button1_clickHander method. Within the button1_clickHander method, the loadURL method is called with the urlAddress.text property passed in. This triggers the StageWebView to load the URL.

The results are shown in Figure 1.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
applicationComplete="application1_applicationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;

private var stageWebView:StageWebView;
private var rect:Rectangle;

protected function application1_applicationCompleteHandler
(event:FlexEvent):void
{
if(StageWebView.isSupported==true){
stageWebView = new StagewebView();
stageWebView.viewPort = new Rectangle(5,80,stage.width-10,
stage.height−90);
stageWebView.stage = this.stage;
} else {
urlAddress.text = "StageWebView not supported";
}
}

protected function button1_clickHandler(event:MouseEvent):void
{
stageWebView.loadURL(urlAddress.text);
}

]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>

<s:TextInput id="urlAddress" left="5" right="80" top="15"
text="http://www.google.com"/>
<s:Button right="5" top="5" label="GO" click="button1_clickHandler(event)"/>

</s:Application>


Figure 1. StageWebView with Google.com loaded

Other  
  •  Developing BlackBerry Tablet Applications : OS Interactions - Splash Screen
  •  Developing BlackBerry Tablet Applications : OS Interactions - Open in Browser
  •  iPhone Developer : Assembling Views and Animations - Transforming Views
  •  iPhone Developer : Assembling Views and Animations - Randomly Moving a Bounded View
  •  iPhone Developer : Assembling Views and Animations - Working with View Frames (part 2) - Other Utility Methods
  •  iPhone Developer : Assembling Views and Animations - Working with View Frames (part 1) - Adjusting Sizes , CGRects and Centers
  •  iPhone Developer : Assembling Views and Animations - View Geometry
  •  Windows Phone 7 : Drawing with Vertices and Matrices - Drawing Primitives
  •  Windows Phone 7 : Understanding Matrix Transformations (part 3) - Drawing Multiple Objects at Different Positions
  •  Windows Phone 7 : Understanding Matrix Transformations (part 2) - Applying Multiple Transformations
  •  
    Top 10
    Review : Sigma 24mm f/1.4 DG HSM Art
    Review : Canon EF11-24mm f/4L USM
    Review : Creative Sound Blaster Roar 2
    Review : Philips Fidelio M2L
    Review : Alienware 17 - Dell's Alienware laptops
    Review Smartwatch : Wellograph
    Review : Xiaomi Redmi 2
    Extending LINQ to Objects : Writing a Single Element Operator (part 2) - Building the RandomElement Operator
    Extending LINQ to Objects : Writing a Single Element Operator (part 1) - Building Our Own Last Operator
    3 Tips for Maintaining Your Cell Phone Battery (part 2) - Discharge Smart, Use Smart
    REVIEW
    - First look: Apple Watch

    - 3 Tips for Maintaining Your Cell Phone Battery (part 1)

    - 3 Tips for Maintaining Your Cell Phone Battery (part 2)
    VIDEO TUTORIAL
    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
    Popular Tags
    Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8