1. Get your Flixel game on Blackberry Playbook

    So, you have a game made with Flixel ? And you wander if it could run on upcoming Blackberry Playbook ? Maybe you want to win the free Playbook too ?

    Flixel ? Flex ?

    If you know already Flixel and Flex, you can skip this paragraph and jump to the next one.

    For those who don’t know about Flixel yet, it’s a popular lightweight game framework based on Flex (an open source framework developed by Adobe, based on the ActionScript 3 language).

    For those who are bit confused about the difference between Flex and Flash, you just need to know that Flex is just another way to produce Flash code (.swf files that will run in the Flash player or with the AIR runtime), as Flash CS5 does, and haXe, and wonderfl.net, and so many others.

    The Flex SDK (SDK = Software Development Kit = the compilator) is free. The royal way to develop with Flex is Flash Builder (formerly known as Flex Builder), an IDE that is developed by Adobe and that is quite expensive (about 500$). But you can use free alternatives, like Flash Develop on Windows, or XCode on MacOS. They use the command line compilator provided with the free Flex SDK. Flash Builder is mainly superior because of its debug capacities, but if, like me, you don’t mind debugging your code without breakpoints, the command line is the way to go.

    Flixel on the Playbook

    The upcoming Playbook tablet by Blackberry will support applications that are compiled with the Flex SDK.

    The process to install the Playbook SDK and simulator is not “plug and play”, but it’s very well described on Blackberry website. With downloads and installations, it’s about 4 hour of work.

    Follow the steps on the Blackberry pages and come back here when you have the simulator running.

    Now we’ll see how to compile your Flixel game for the Blackberry.

    So far you were compiling your game with this command line :

    
    /flex_sdk_path/bin/mxmlc MyGame.as
    

    And you get a MyGame.swf that you can play on Flash player.

    Great. Now here is how you’ll compile your Flixel game for Blackberry. First you’ll have to create an xml file called MyGame-app.xml. Put it in the same directory as your MyGame.swf file, and enter the following text :

    
    <?xml version="1.0" encoding="UTF-8"?>
    <application xmlns="http://ns.adobe.com/air/application/2.5">
        <id>com.yourcompany.MyGame</id>
     <versionNumber>1.0.0</versionNumber>
        <filename>MyGame/filename>
     <name>MyGame</name>
     <copyright>Your company</copyright>
        <initialWindow>
            <content>MyGame.swf</content>
            <visible>true</visible>
            <systemChrome>none</systemChrome>
            <transparent>true</transparent>
            <width>1024</width>
            <height>600</height>
        </initialWindow>
    </application>
    

    Now run the following command to compile your game for AIR :

    
    /playbook_sdk_path/bin/mxmlc +configname=air MyGame.as
    

    And you get a MyGame.swf for the AIR runtine (nothing specific to the Playbook SDK so far).

    Now you need to package the MyGame.swf for the Playbook. You need to create a 90x90 icon file (let’s say it’s called “icon.png”) and an xml file called “blackberry-tablet.xml”. Put these 2 files in the same directory as your .swf file.

    Edit the xml file and enter the following :

    
    <qnx>
      <initialWindow>
       <systemChrome>none</systemChrome>
       <transparent>true</transparent>
      </initialWindow>
      <publisher>Your Company</publisher>
      <category>core.games</category>
      <icon>
       <image>icon.png</image>
      </icon>
    </qnx>
    

    And now the final command that will package the swf, install it and launch it on the Playbook simulator.

    Go to the directory where is located your MyGame.swf and type the following command (more info about the device IP and developer password)

    
    /playbook_sdk_path/bin/blackberry-airpackager -package MyGame.bar -installApp -launchApp MyGame-app.xml icon.png blackberry-tablet.xml MyGame.swf -device 192.168.X.Y -password developerpassword
    

    And here you are, the game should launch on the Playbook simulator after it’s packaged. Next step is to adapt the game for the mobile environment. My game is very simple and there were very few changes to make but it really depends on your game. Of course the Playbook SDK comes with additional libraries (Device, AudioManager, MediaServiceConnection, MediaPlayer, TextInput, Dialogs, …) that you can implement for a better user experience.

    Then you have to sign your game and to submit it to Blackberry for approval, and the free Playbook will be yours (you have still 15 days, hurry up).

    UPDATE : My game Icual has been approved and will be available on the Playbook store.