Return to Snippet

Revision: 43223
at March 19, 2011 11:27 by chrisaiv


Initial Code
package
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import qnx.ui.buttons.Button;
	import qnx.ui.buttons.LabelButton;
	
	// 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 ASBlackberry01 extends Sprite
	{
		public function ASBlackberry01()
		{
			var helloButton:LabelButton = new LabelButton();
			helloButton.label = "Hello World!";
			helloButton.x = (stage.stageWidth - helloButton.width)/2;
			helloButton.y = (stage.stageHeight - helloButton.height)/2;
			
			var myFormat:TextFormat = new TextFormat();
			myFormat.color = 0xAA0000;
			myFormat.size = 24;
			myFormat.italic = true;
			myFormat.align = "center";
			var text:TextField = new TextField();
			text.text = "Close";
			text.setTextFormat(myFormat);
			
			var closeButton:Button = new Button();
			closeButton.addChild(text);
			closeButton.addEventListener(MouseEvent.CLICK, closeWindow);
			closeButton.x = (stage.stageWidth - closeButton.width)/2;
			closeButton.y = helloButton.y - helloButton.height;
			
			addChild(helloButton);
			addChild(closeButton);
			
			stage.nativeWindow.visible = true;
		}
		
		private function closeWindow(event:MouseEvent):void{
			stage.nativeWindow.close();
		}
	}
}

Initial URL
http://chrisaiv.com/post/4187704195/developing-for-blackberry-playbook-using-flash-cs5-1

Initial Description
What makes the Blackberry Playbook so cool is that Adobe AIR is natively installed. So if you're interested in making a Playbook app, all you need to do is fire up Flash Pro and create an AIR 2.5 file.

Initial Title
AS3: Blackberry Playbook Example

Initial Tags

                                

Initial Language
ActionScript 3