BlackBerry PlayBook Adobe AIR Developer Tips
Here are a few tips for developing on the BlackBerry PlayBook with AIR:
DISCLAIMER: Some tips will change as the PlayBook OS changes. The BlackBerry Tablet OS and SDK are in beta form and will definitely change for production release.
Application Icon
In the current beta build of the BlackBerry Tablet OS SDK you can find the default icon. Its not a full PSD template but if you want to create an icon like the 3d looking box its a start for now. The icon is found at the following path relative to your blackberry-tablet-sdk-0.9.0 sdk path: {sdk_root}/samples/icons/blackberry-tablet-default-icon.png.
Browse For Image (this will likely change)
If you check CameraRoll.supportsBrowseForImage
and CameraRoll.supportsAddBitmapData
the currently beta simulator will say false and false. A workaround to get access to the Photo folder is do use this following code:
protected function button2_clickHandler(event:MouseEvent):void
{
browseFile.browseForOpen("Open File");
browseFile.addEventListener(Event.SELECT, selectedFileHandler);
}
protected function selectedFileHandler(event:Event):void
{
var stream:FileStream = new FileStream();
stream.open(browseFile, FileMode.READ);
var bytes:ByteArray = new ByteArray();
stream.readBytes(bytes);
}
This brings up PlayBook UI like this:
Reading & Writing Files (permissions on certain folders might change over time)
Here is some code to write data to file and then read it. This is useful for pulling data off the web to store on the device (ie: images, xml, etc…).
trace("newFile: " + newFile.nativePath + " - " + newFile.exists);
var stream:FileStream = new FileStream();
stream.open(newFile, FileMode.WRITE);
trace("Writing Data");
stream.writeUTF("Here is some text");
stream.close();
stream = new FileStream();
stream.open(newFile, FileMode.READ);
trace("Reading Data");
var text:String = stream.readUTF();
trace(text);