05-19-2011 12:25 PM - edited 05-19-2011 12:28 PM
My app is a game, so I don't use many of the off-the-shelf QNX components. All of the interactive elements in Twystem are sprites, with hand-crafted gesture handling.
The only place where I use a QNX component is when the game complete and I prompt the user to enter a name for the high-score list. Unfortunately, this creates a pain-point for application portability. Using the QNX PromptDialog class (and the on-screen keyboard) causes an unhandled exception when executed on the desktop (and prevents me from easily deploying the app on iOS or android).
So I'm in the process of creating my own on-screen keyboard and prompt implementations (hat-tip to Matt Rix, with his Scorekeeper app, for inspiration about the custom keyboard). With a custom keyboard, I'll be able to get rid of all QNX dependecies, and maintain 100% portability between different tablet devices.
It kind of annoys me that the PlayBook doesn't use standard Flex components. (I can understand why they rolled their own implementations, to optimize for the device's capabilities, but I don't understand why they didn't use the same package & class names as the standard flex framework.)
But my case is skewed because I'm developing a game, and I don't need many standard GUI components anyhow.
What do you guys think? Are you using the QNX components, the standard Flex components, or are you rolling your own? Are you concerned about portability?
05-19-2011 01:37 PM
I don't think you will need to develop your own keyboard. You can still use the default one (on PlayBook, desktop, or other platforms) by just basing your dialog around a standard text field.
As for the QNX components themseleves, they have a very nice look to them, and helps keep a little consistancy across the platform. If you use a lot of them it does make porting more difficult, but there are more generic versions of almost every component avaliable elsewhere. I don't think that it would really be too bad.
05-20-2011 09:43 AM
05-21-2011 02:35 PM - edited 05-21-2011 07:36 PM
Flex components are certainly the easiest as they are already portable. You can leverage this for other platforms while still using the qnx components on Playbook by using conditional compilation (see here: http://help.adobe.com/en_US/flex/using/WS2db454920
Basically, you enclose code in CONFIG:: PLAYBOOK or CONFIG::GENERICFLEX blocks, for example, and manually toggle the config flags in your project properties when building for a particular platform. There is no space between :: and PLAYBOOK, simply avoiding emoticons here. Under Flex Compiler in your project properties, when building or testing on the desktop, use -define+=CONFIG:: PLAYBOOK,false -define+=CONFIG::GENERICFLEX,true. No spaces in between anything in the define statements themselves. I'm sure there is a way using ant to automate this. I'll let you know when I have a chance to do some exploring. In any case, you should be able to abstract this out quite easily. For example, to show a dialog box, your code could call a function such as the below:
private function showDialog(headerTexttring, messageTexttring):void
// use qnx methods to show dialog box
// show dialog box using generic flex methods
For the text field, use a similar method. Declare, for example, a textField object of type qnx.ui.text.TextInput if CONFIG:: PLAYBOOK, or the flex equivalent if CONFIG::GENERICFLEX. Wrap any code specific to one implementation in the conditional compilation blocks.
Of course, you would also want to wrap import statements with the appropriate blocks as well.
The approach presented above will certainly prove easier than reimplementing core functions yourself and will provide ideal consistency across platforms while allowing you to focus on what your customers care about - gameplay.
05-21-2011 04:22 PM
05-21-2011 04:33 PM
Works fine for me, Flash Builder 4.5. Thought it might be a flex project only feature, but an AS3 mobile project works fine.
public class Main extends Sprite
public function Main()
// support autoOrients
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
ActionScript compiler properties:
-locale en_US -define+=CONFIG::RELEASE,false
Compiler pops up not definiton not found erorrs when set to false, runs properly when true.
05-22-2011 01:01 AM - edited 05-22-2011 01:03 AM
Please don't recommend to anyone that they be using Flex on mobile, that is doing no benefit to anyone! Gives a bad name to flash, to AIR and to PlayBook apps. Use AS3.
For the most part, the QNX Component set IS portable, and works well on all devices. The majority of the UI components are simple AS3 components. I have an app using QNX ScrollPane's deployed on iOS, Android and Playbook right now.
Anywhere where there are PPSChannel depenancies you want to avoid if you can, it definately slows down development. We don't use the native Dialog's, or native textFields for that reason.