
Since Blackberry announced the Playbook SDK for AIR at Adobe MAX, there has been considerable excitement around the platform. In fact, Blackberry is planning to give free Playbooks to developers having apps approved for it in the Blackberry App World by the time they release the Playbook in early 2011.
As a Blackberry Smartphone owner, I for one am very excited about the Playbook tablet, and so I decided to sacrifice a little blood to the bleeding edge and see what it takes to get a PureMVC-based app running on it.
The answer: I didn't even need a Band-Aid!
Suffice it to say, that when you get the HelloWorld app going in the Blackberry Simulator, you are now ready to try HelloPlaybook, and see how easy it is to separate your AS3 code according to the Model, View & Controller pattern using PureMVC.
The 0.9.0 version of the BlackBerry Tablet OS SDK didn't support MXML projects, so I ported the classic HelloFlash demo for PureMVC, which is all AS3. The primary difference between the two demos is that there is no mouse wheel to use for scaling all the sprites up and down, so I added +/- buttons to the interface for that. Also, I needed to add a close button to the UI, since this isn't running on a desktop with a close button on the system chrome.
The premise of the demo is simple: There is a colored square bouncing around. Drag it and it spits out out more squares. Click the +/- buttons to scale all the sprites up or down in size.
They're all self-directed sprites, but individually mediated. This means that while they bounce around on the stage of their own accord, their Mediators interact with the system on their behalf, receiving notifications and in turn informing them, or listening for events on the sprites and sending off notifications. For instance, when the scale buttons are clicked, a mediator for the stage hears this and dispatches a notification called SPRITE_SCALE. This notification is heard by all the Mediators for all the sprites, and they all tell their sprites to scale up or down accordingly. A Proxy class is used to store data about the sprites, such as the color of the next sprite to create, and a unique ID for it.
It's a very simple application, but it shows how the PureMVC apparatus interacts with the view hierarchy.
Getting your environment set up is by far the toughest part at this
point, and the pitfalls for me came down to what versions of what tools
were required. I ended up using FB 4.0.1 with the 0.9.0 version of the Tablet
OS SDK for AIR 2.5. My old version of VMWare Player was no good; you
need 3.0 or greater to support the simulator.
- You must have Adobe Flash Builder 4.0.1 or greater installed.
- You must have the AIR 2.5 for BlackBerry Tablet OS SDK (version 0.9.0) installed.
- If you are using Flash Builder Burrito, you must have Playbook SDK 0.9.1 installed. (This was just released, I haven't tried it)
- You must have VMWare Player 3 installed
- You must have the Blackberry Playbook simulator installed and running.
Finally, download the project source code here:
http://trac.puremvc.org/Demo_AS3_AIR_HelloPlaybook
If you're new to PureMVC, have a look under the Docs section of the website for the Framework Overview and Best Practices documents to get started.
UPDATE:
Moving beyond HelloPlaybook, which is purely ActionScript based, I wanted to discover whether it would be feasable to build a well-performing app for the Playbook using AIR. The answer was: YES. I built a touch-focused strategy game, also testing a long held belief by game developers that MVC and Flex / AIR were 'too heavy' for gaming.
The game (called Dungeon Joe), has been submitted to the Blackberry AppWorld and is awaiting approval. In the meantime, I've ported it to the desktop (zero-code changes) and tested it on an HP TouchSmart computer to get the feel for the finger-swipe navigation that is at the heart of the game. Install and play the desktop version and watch the video of the HP TouchSmart test here: http://dungeonjoe.com
-=Cliff>