Posted By

chrisaiv on 03/19/11


Tagged

AIR as3 blackberry playbook


Versions (?)

AS3: Blackberry Playbook Example


 / Published in: ActionScript 3
 

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

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.

  1. package
  2. {
  3. import flash.display.Sprite;
  4. import flash.events.MouseEvent;
  5. import flash.text.TextField;
  6. import flash.text.TextFormat;
  7. import qnx.ui.buttons.Button;
  8. import qnx.ui.buttons.LabelButton;
  9.  
  10. // The following metadata specifies the size and properties of the canvas that
  11. // this application should occupy on the BlackBerry PlayBook screen.
  12. [SWF(width="1024", height="600", backgroundColor="#cccccc", frameRate="30")]
  13. public class ASBlackberry01 extends Sprite
  14. {
  15. public function ASBlackberry01()
  16. {
  17. var helloButton:LabelButton = new LabelButton();
  18. helloButton.label = "Hello World!";
  19. helloButton.x = (stage.stageWidth - helloButton.width)/2;
  20. helloButton.y = (stage.stageHeight - helloButton.height)/2;
  21.  
  22. var myFormat:TextFormat = new TextFormat();
  23. myFormat.color = 0xAA0000;
  24. myFormat.size = 24;
  25. myFormat.italic = true;
  26. myFormat.align = "center";
  27. var text:TextField = new TextField();
  28. text.text = "Close";
  29. text.setTextFormat(myFormat);
  30.  
  31. var closeButton:Button = new Button();
  32. closeButton.addChild(text);
  33. closeButton.addEventListener(MouseEvent.CLICK, closeWindow);
  34. closeButton.x = (stage.stageWidth - closeButton.width)/2;
  35. closeButton.y = helloButton.y - helloButton.height;
  36.  
  37. addChild(helloButton);
  38. addChild(closeButton);
  39.  
  40. stage.nativeWindow.visible = true;
  41. }
  42.  
  43. private function closeWindow(event:MouseEvent):void{
  44. stage.nativeWindow.close();
  45. }
  46. }
  47. }

Report this snippet  

You need to login to post a comment.