Posts Tagged ‘AIR’

Playbook development with device specific libraries using QNX PPS and why is ADL throwing errors

Saturday, February 5th, 2011

The Playbook SDK of Blackberry provides additional libraries to use device capabilities which aren’t available in the standard Flex Hero SDK. These Blackberry specific libraries provide access to the controls of the device and contain the QNX specific UI Controls, MediaPlayer/MediaServiceConnection and Pop Dialogs. Blackberry (or QNX) realized the integration using the messaging system of QNX, called PPS Service (QNX Persistent Publish/Subscribe). You can find additional information about PPS here.

AudioManager (qnx.system.AudioManager)

Provides access to the Audio Controls of the Playbook.

MediaServiceConnection (qnx.media.MediaServiceConnection)

Allows the communication between application and the music controller in the upper controlbar of the Playbook.

Device (qnx.system.Device)

Device specific information and allow the application to monitor the battery state of the device.

QNXApplication (qnx.system.QNXApplication)

Allow the application to monitor if the device runs out memory or if the user makes a  Swipe Down Interaction.

MediaPlayer (qnx.media.MediaPlayer)

Build-in MediaPlayer of the BlackBerry Playbook

Dialogs (qnx.dialog.*)

The dialogs are native QNX OS dialogs and using PPS to communicate with your AIR application.

TextInput (qnx.ui.text.TextInput)

Provides the option to define which Keyboard layout will used by defining the type using the parameter “keyboardType”. The image below shows all the available keyboard types.

ADL throws an error when using Playbook specific stuff

If your application is using any of these class above and you try to run your application use ADL (AIR Debug Launcher), the ADL will throw an error (VerifyError: Error #1014: Class qnx.pps::PPSChannel could not be found.) that compiler can’t find the PPS specific class qnx.pps.PPS or qnx.pps.PPSChannel. This error will thrown because these classes are only available on the device or emulator.

I’m personally prefer to develop using the ADL and  only do my final tests using the device or emulator. So I found two solutions to avoid that ADL is throwing the error described above.

1.Solution: Monkey Patch the class PPSChannel

This solution works for the QNX TextInput. Monkey Patch describes the overlaying the original class by adding a modified class with the same name and package into your project.

  1. Open the Library Path in Project Properties
    (File -> Properties -> Flex Build Path -> Library Path)
  2. Selected the qnx-air.swc and change the Link Type from External to Merge into Code
  3. Create a package  called qnx.pps in your project and add a new class PPSChannel into the created package. Use a simple file (File -> New -> File) , otherwhise Flash Builder 4 will not create the class when using ActionScript class.
  4. The class PPSChannel should look like the code below
    package qnx.pps
    {
    	public class PPSChannel
    	{
    
    		public function PPSChannel(){
        	        }
    	}
    }
  5. Recreate the project!
  6. Run the application using ADL

You can download a Flex Project with this solution here.

PS: Don’t forget to remove the class and switch back the Link Type to External when running the application on the emulator or device!

2.Solution: Conditional Compilation

This solutions works perfect when using any of the device integration like AudioManager, MediaServiceConnection, Device or QNXApplication. Because these things can’t be used without running the application on the device or emulator, it makes sense to them off while developing with ADL.

Conditional Compilation allows to include or exclude code based on constants added to the compiler arguments in Flash Builder or using MXMLC.

The constants of the conditional compilation should look like line below.

-define+=CONFIG::device,true

In the source code of the application, you have to add the constant above the functions and attributes of the class which should be included or excludes by compilation.

CONFIG::device
public var audioManager:AudioManager;

CONFIG::device
public function init():void
{
	CONFIG::device
	{
		try{
			audioManager = AudioManager.audioManager;
			audioManager.addEventListener(AudioManagerEvent.OUTPUT_LEVEL_CHANGED, handleOutputLevelChanged);
			audioManager.addEventListener(AudioManagerEvent.OUTPUT_MUTE_CHANGED, handleOutputMuteChanged);
		}
		catch(error:Error)
		{}
	}
}

Set the parameter to “false” running the application with ADL or to “true” using the emulator or device.

Adobe Flex 4 LiveDoc for Conditional Compilation

The second solution helps also if you develop a multi device/screen application and you need a deep integration into the device without creating an extra project for each platform. The developer has only to change the parameter before exporting/building for a specific device or screen.

Stay tuned! At the moment, I’m working on a Flex library and AIR client which allow to trigger all the Playbook device events.

Links:

Documentation of Playbook ActionScript 3 Libraries

Tripreport zur Adobe MAX 2008 Europe

Friday, December 12th, 2008

Adobe MAX 2008 Europe

Die diesjährige Adobe MAX in Europa stand ganz im Fokus von Flex 4 und Flash Catalyst (Codename: Thermo). Insbesondere das Zusammenspiel zwischen Flex und den Creative Suite Produkten durch die Nutzung von Flash Catalyst soll den Workflow zwischen Designer und Entwicklern verbessern, bzw. vereinfachen.

Eine richtig coole Session war “Flash Player Internals” mit Jim Corbett. Da ich mich noch nie mit der Arbeitsweise des Flash Players auseinandergesetzt habe, war es wirklich spannend zu erfahren, was in dem Player intern passiert.

Auch die Session von Christophe Coenrats zu “Liberate Your Data with Adobe AIR, BlazeDS and LiveCycle Data Services” war spannend. Er stellte seinen Ansatz zur Implementierung einer ORM-Frameworks für Sqlite in Adobe AIR vor.

Ganz unterhaltsam war auch die Session von Duane Nickull über “Adobe Adoption of Web Services, SOA, and REST”. Es war zwar nicht ganz neues dabei, aber Duane hat das Thema ganz gut auf den Punkt gebracht.

Die General Sessions und Sneak Peak genial moderiert, insbesondere Ben Forta als Superagent. Auf jeden Fall war der Unterhaltsfaktor hoch.

Von den Labs auf der Adobe MAX war ich enttäuscht. Die beiden Labs, welche ich besuchte habe, ich vorzeitig verlassen. Inhaltlichen waren diese eher für Anfänger oder weniger Erfahrung konzipiert. So bin stattdessen wieder in Session rein.

Im ganzen war der Trip ne super Sache, viele spannende Sessions und Präsentationen. Auch war es wiedermal schön einige alte Adobe Kollegen wiederzutreffen.

Flash und Flex wird zur Flash Plattform gebündelt

Friday, November 21st, 2008

Adobe bündelt alle Flash und Flex Produkte unter Flash Plattform. Anscheinend sollen alle Produkte weiter zusammenwachsen. Zur gehören Plattform gehören die IDEs Flash CS4, Flex Builder 3, Flash Catalyst. Als Server werden der Flash Media Server und BlazeDS aufgeführt, was Nahe legt das Flash Remoting wohl zukünfigt durch BlazeDS ersetzt wird. Als Runtime werden der Flash Player und AIR aufgelistet. Die LiveCycle ES Data Service tauchen nicht explizt auf, sondern es wird nur das gesamte LiveCycle ES Paket neben Coldfusion als Adobe Server aufgelistet.

Die Übersicht über die neuformierte Flash Plattform findet ihr hier: Link