Building a Web Browser App for Blackberry Playbook Simulator
The blackberry playbook simulator doesn't yet include the web browser application, but I found it pretty easy to write my own using the qnx.media.QNXStageWebView class and calling the loadUrl method. This class also has a loadString(code, mimeType) and executeJavaScript method that looks interesting.
Here's the code for a simple browser:
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.text.TextField;
import qnx.media.QNXStageWebView;
import qnx.ui.buttons.LabelButton;
import qnx.ui.text.TextInput;
// The following metadata specifies the size and properties of the canvas that
// this application should occupy on the BlackBerry PlayBook screen.
[SWF(width="1024", height="600", backgroundColor="#cccccc", frameRate="30")]
public class PlaybookTest extends Sprite
{
private var addressInput:TextInput = null;
private var webView:QNXStageWebView = null;
public function PlaybookTest()
{
addressInput = new TextInput();
addressInput.x = 10;
addressInput.y = 10;
addressInput.text = "http://foundeo.com/";
var goButton:LabelButton = new LabelButton();
goButton.label = "Go";
goButton.x = addressInput.width + 10;
goButton.y = addressInput.y;
goButton.addEventListener(MouseEvent.CLICK, go);
var closeButton:LabelButton = new LabelButton();
closeButton.label = "Close";
closeButton.addEventListener(MouseEvent.CLICK, closeWindow);
closeButton.x = (stage.stageWidth - closeButton.width) - 10;
closeButton.y = 10;
webView = new QNXStageWebView();
webView.stage= stage;
webView.autoFit=true;
webView.viewPort = new Rectangle(10,100,stage.stageWidth,stage.stageHeight-100);
webView.enableCookies = true;
webView.enableJavascript = true;
webView.enableScrolling = true;
webView.loadURL("http://foundeo.com");
addChild(addressInput);
addChild(goButton);
addChild(closeButton);
stage.nativeWindow.visible = true;
}
private function closeWindow(event:MouseEvent):void{
stage.nativeWindow.close();
}
private function go(event:MouseEvent):void {
webView.loadURL(addressInput.text);
}
}
}
Here's a screenshot of the app:
Tweet
Related Entries
- Getting Started with Blackberry Playbook App Development - November 17, 2010
- Blackberry WebWorks AJAX Problems - May 9, 2011
- Geolocation API for Adobe AIR? - October 8, 2008
Trackbacks
Comments
I didn't realize it was undocumented :)
Do you know how to display local HTML files? If this is possible, where do you keep the local files, and will they be able to link to one another inside the browser?
app://foo
where app:// represents the application install directory and "foo" is some file underneath it.
loadURL("ce://file.htm") loadURL("app://ce/file.htm") loadURL("file://ce/file.htm") loadURL("file:///ce/file.htm")
Nothing happens.
The "ce" directory is recreated in the bin-debug directory. What am I missing?
loadURL("ce://file.htm") loadURL("app://ce/file.htm") loadURL("file://ce/file.htm") loadURL("file:///ce/file.htm")
Nothing happens.
The "ce" directory is recreated in the bin-debug directory. What am I missing?
http://www.flex888.com/511/adobe-air-url-schemes-for-local-access.html
So - yesterday I was speaking with Brian Rinaldi. And he mentioned that he saw oddness using app:// syntax under Android. THat may be at play here.
Instead of using app://, you could use FIle.applicationDirectory.nativePath. That should give you a pointer to the directory - and then you just append the file name.
That's not _exactly_ the syntax, but you get the idea I hope.
New topic: Has anyone successfully signed a PlayBook bar file with existing BlackBerry keys (from phone app development?) The java code signing GUI doesn't like bar files, and I just don't understand the command line syntax!
Post a Comment
Recent Entries
- Writing Secure CFML cfObjective 2013 Slides
- Upgrading to Java 7 on Linux
- J2EE Sessions in CF10 Uses Secure Cookies
- Learn about ColdFusion Security at cfObjective 2013
- Session Loss and Session Fixation in ColdFusion
- FuseGuard 2.3 Released
- CKEditor Spell Checker Plugin
- Adobe Says Go Ahead and Upgrade your ColdFusion JVM


add to del.icio.us


