Official Adobe page about recent news

Adobe has put up a more official page about the recent news, confirming that they will not continue work on Flash for mobile and reaffirming their commitment to such technologies as Flash Player on the desktop, AIR for the mobile and desktop, Flash Builder and Flash Professional. Go read for yourself!

Meeting of Montreal AUG

The Montreal Adobe User Group will be holding their next meeting on Wednesday December 7th, 2011 at the Istory II Bar Billard. The main topic as you can imagine revolves around the recent Adobe news regarding Flash on mobile. Go here to sign up. 

Unfortunately I cannot make it since I have prior commitments that day.


Flex goes to Apache

Needless to say that due to last week's Adobe blog post, their communication skills leave much to be desired. The entire Flash/Flex community is up in arms and wondering about the future. A couple of follow up blog posts were made by Adobe employees (here and here), but that asked more questions than it answered. Well as of last night, one of those follow up blog posting was updated (go here and scroll down after the red comment) in an attempt to provide more clarity. Here is a summary:

  • Current Flex SDK development work will be completed (new components and super fast compiler)
  • The Flex SDK, BlazeDS and more will be donated to Apache Software Foundation, Adobe will have people on the Open Source Flex SDK management team
  • Future versions of Flash Builder will be released with previously communicated new features
As for the future, Adobe believes that Flex is still the best solution for the development of large enterprise applications. Eventually, HTML/JavaScript will catch up in this regard, maybe 5-10 years from now, but for the near future, Flex is still the better solution. And I agree, until I see an update to the JavaScript language, I don't see how it can surpass Flex for large application development.


When is Javascript going to be updated?

Do you know since when has JavaScript been around? Well if you don't, I'm going to tell you. 1995. That's 16 years ago and since then, it feels like the language has not evolved one bit. Well at least it doesn't feel like it. Having worked with ActionScript allot over the recent years, it makes me yearn for the day that JavaScript takes on some of its characteristics. So here are a few random thoughts on the subject:

  • Why is everything still loosely typed? Why can't I declare the data type of my variable. Once we are allowed to do this, it also means we have greater support for the language in our development tools, meaning less typo mistakes and shorter development times.
  • When will we be able to finally declare a class like any normal person can. You know by using the class keyword. No more of this everything is a function mumbo jumbo. Proper class inheritance would be nice as well.
  • How about having a compiler that can run through our code, to advise us in advance of any syntax errors. Rather than random discovery at run-time of any simple programming errors.

Times are changing: Flash and Flex

They say that the only constant is change. And another great example was given to us this week following Adobe's announcement (article 1, article 2 and article 3) about the future of Flash on mobile browsers - that basically there isn't any. For the last couple of days I've been thinking about how to write this blog post, so here goes :)

Were all the Flash haters right?
Anyone who "hates" is never right. They are most likely ignorant and perhaps even mis-informed. For 7 years now, since 2004, I've been developing web applications using Flex for my personal projects and at my job. At my job, I am perhaps one of maybe 3 developers who have used Flex at home and work and loved the capabilities the technology offers. Others used it cause they had too, and some wouldn't touch it with a 10 foot pole. That's fine, we are all different people. But you know what the most important thing is, I tried and I learned something new. I did something not many people can say they did and because of it, I am better developer today than was back in 2004. For 7 years, I have been ahead of the curve, doing things that were not possible or very time-consuming to do without Flex. Basically what I am saying is that I wasn't going to stand still waiting for HTML/JavaScript/CSS to catch up. And I must say that was thanks to Stacy Young for giving me a CD labeled "Royale Beta" back in the Fall of 2003.

What about my skills set, my job?
So finally in 2011, HTML/JavaScript/CSS have finally caught up. Well at least up to a certain point, there are still things you can't do in a browser that only the Flash Player can do. But with the rapid evolution of browsers these days, especially for Firefox and Chrome (IE is still slow), they will soon catch up, but it will still take some time. It might still take 10 years before browsers have totally replaced what the Flash Player can do it. So what does a Flex developer like myself do? Am I out of a job? Am I useless? Nope, au contraire, I have just spent 7 years acquiring knowledge in how to better develop web applications and I thus will continue to do so. Just means I am using different tools to do so. Actually over the past year I have already started doing more HTML/JavaScript/CSS developement than ever before and I have been applying  my Flex skillset to all the JavaScript development I have been doing. I have created my own jQuery DataGrid widget, you can set the columns to display and specify a labelFunction for each column object. Sounds familiar? :)

Let's no forget
Since 1996 we have been using the little plugin that could to stream and watch Dallas Cowboys games which were not available on national TV (ok, that was just me), share funny/sad/dramatic/historical/great/not so great moments with family and friends on YouTube, watch sport highlights and much more. Were would we be today without the Flash Player? Probably stuck in the web technology stone ages. The web is a better place cause of the Flash Player and hopefully the future will be better because of it.

What Adobe is saying
But don't just listen to me, some Adobe employees have made some posts as well in the days since the announcement. Mike Chambers has a great post here and then there is one here from a couple of product managers.

What's next?
Well, I'm going to keep doing what I've always been doing, creating great web applications. And I'm going to start by bitching as to why JavaScript hasn't grown in 15 years. Oh, but that's another blog post all in itself :)


ActionScript 101

New to ActionScript (or Flex in general) and don't know how to learn the basics? Need a quick crash course? Then I have the hyperlink for you! Adobe has put together some small articles about the basics of ActionScript 3, such as language syntax, how to declare variables, namespaces and much more. The first article which talks about ActionScript Syntax is here and once you are done with that one, at the bottom of the page are the links to the subsequent articles.

So go get started if you are new to ActionScript/Flex/AIR, or share it with a friend/colleague who is looking to get started in this domain.


MAX 2011 Sneak Peeks

One of the most anticipated portions of any MAX Conference is the Sneak Peeks event. This is when the Adobe wizards take the time to leave their laboratories and show us what features they have been working over the last little while. Features that *might* make their way into some product in some future release. This year was no exception, so follow this link to see about a dozen sneak peeks from MAX 2011. My favorites include Image Deblurring, GPU Parallelism and Reverse Debugging in Flash Builder.


New components in Flex 4.6

One of the best Flex Evangelists out there, Christopher Coenraets, has recently made a blog post where he demonstrates the newest components added to the Flex 4.6 SDK. It is a must see for those developing mobile applications, as these new components were added specifically for this use case. My favorites are the Spinner (like a regular ComboBox) and the Callout components, cause I remember looking for components such as these earlier this summer when I was building some prototype applications (for Android). So what are you still doing here, go see the demo!


Montreal User Group meeting tomorrow

For those interested, the Montréal Adobe User Group is having a meeting tomorrow night from 6:00 PM to 9:00 PM to recap the information from last week's Adobe MAX. Click here for full details and to sign up.


Learning the basics of HTML5

Yes, yes, I know. This is my blog about Flex, but you know what, it is always good to learn and know as much as you can. Cause face it, HTML is here to stay and we need to know the most we can't about this latest specification (version 5). The version 5 specification is finally catching up to the things we already have in Flex, but I still don't understand why JavaScript is not strongly typed :(

Anyways, take a look at this video, which is a presentation from Adobe MAX 2011 from a Mozilla developer. He talks about the new tags, form elements, open video codecs and then some.

The future of Flash Platform

Although I did not attend MAX this year, I did find this nice video about several Adobe Product Managers discussing the changes coming to the Flash Platform in 2012. Its great video that shows the performance improvements they will be making, the 10x faster Flex compiler, new encryption/decryption APIs, more components converted to the Spark framework and a feature called "Workers" (think of this as threads, but its not threads within the Flash Player).

So don't delay, get the lowdown on whats coming down the pipe for the Flash Platform!


Montreal AUG meeting August 3rd

There is another Montreal Adobe User Group meeting coming up this week, on Wednesday August 3rd to be specific. This one is being held at a pool hall like the last one and will involve open talk about the mobile development. So if you are interested in dropping by, there is a $20 entry fee (hey, there's beer involved) and you can sign up here.


Fixing multiple parsley result handlers being called [Update]

This passed week I was testing my application and noticed some odd behavior. After some debugging, I noticed that two command result handlers were being called, when in fact only one of them should be. The application was built using the Parsley framework, so to quickly explain the problem and solution, here is what was happening:
  1. Application was dispatching the MyEvent1 event
  2. The MyCommand1 was being executed and the MyCommand1 result handler was being called
  3. Then the problem, the MyCommand2 result handler was being called.
So why was the MyCommand2 result handler being called? Because Parsley didn't know any better based on how I coded both handlers. Here is how both handlers were coded:

public function onResult( event:MyEvent1 ):void

public function onResult( event:MyEvent2 ):void

In both cases, the remote java call returns void, so I declared only one parameter for each function, the event that dispatches the command class. Since I didn't specify the event class name (the type as Parsley calls it) in the CommandResult metadata tag, Parsley will use the 2nd parameter to determine the type. Oh, but I don't have a second parameter! Hence the problem, so Parsley just ended up calling both handlers. So there are two ways to solve this problem...

1) Add another parameter to the handler function of type Object that will not be used, like so:

public function onResult( obj:Object, event:MyEvent1 ):void

public function onResult( obj:Object, event:MyEvent2 ):void

2) Declare the event type in the metadata tag, like so:

public function onResult( event:MyEvent1 ):void

public function onResult( event:MyEvent2 ):void

I ended up using solution #1 and then I only had the one result handler being called, which is what I wanted.

UPDATE: Actually good catch by Devin, if you just use the [CommandComplete] metadata tag, then your handler method only requires one parameter, the associated event object. Totally missed this one while reading the documentation.


AIR 3.0 beta and Flash Player 11 beta available!

Well a big day today, shows that Adobe is busy at work even though we are in the middle of the summer. Today Adobe has announced the beta availability of the next major versions of AIR and Flash Player.

The AIR 3 beta, is a run-time only beta at the moment, so as to test backward compatibility with applications built with the AIR 2.7 SDK. The AIR 3 SDK beta will be made available at a later date. Major speed improvements are the highlight of this release, but more details will come I'm sure.

As for the Flash Player 11 beta, we have a bit more details on this side. The next version of our little player that could will contain Stage 3D APIs, 64-bit support (finally!), HD Surround Sound, Socket Progress Events (you can now built FTP clients), G.711 audio compression and H.264/AVC for higher quality video encoding. Well that was a mouthful, go check it out!

Great AIR for Android tutorial

As I was building my first AIR application for Android, I was naturally doing some research into how to get started. No article helped me more than this one from Narcico Jaramillo from Adobe. It properly explained the basics about the new Flex components that you need to use for mobile development and also had some links to some great step-by-step tutorials (scroll all the way to the bottom of the page) on how to build your first application using Flash Builder.

Kudos to Narcico for the great articles!


Montreal AUG meeting July 6th

There is another Montreal Adobe User Group meeting coming up next week, on Wednesday July 6th to be specific. This one is a little different than the previous ones, it's being held at a pool hall and will involve open talk about the designer/developer workflow using Photoshop, Flash Catalyst and Flash Builder. So if you are interested in dropping by, there is a $20 entry fee (hey, there's beer involved) and you can sign up here.

My first Flex 4.5.1 android mobile application

So I finally got myself an Android tablet this passed week and needless to say I've been playing with it ever since. And of course today, I build my first application with it using both the Android SDK and Flex 4.5.1. But it wasn't just click a button and voila! I had to go thru several steps and just wanted to note them all here, just in case someone else is getting started in the mobile development environment anytime soon and will be going thru the same thing as I experienced.

Before I get started, the tablet I bought is the Asus Eee Pad Transformer TF101, which you can read all about here. Its a nice 10 inch tablet at an affordable price of $399 CAD. And my PC is running Windows 7 Service Pack 1.

So here are the steps that I took to build my first "Hello World" application:
  1. Enable Debug mode on your device.
  2. Download and install the USB driver for your device. The Android web site links to whole list of OEM sites, so you can find the one for your device. In my case, Windows 7 installed it on its own.
  3. Download the latest Android SDK from here. I downloaded the zip version and extracted to my folder of preference.
  4. Since we are using Eclipse for our development, install the ADT plugin by following the instructions on this page. I am using Eclipse Helios (3.6).
  5. Once the ADT plugin is installed, start Eclipse and go to Window > Android SDK and AVD Manager. You can now download and install some extra components related to the Android SDK. The most important one as I recall is the "Android SDK Platform-Tools".
  6. Again within the Android SDK and AVD Manager (see above step), under Virtual Devices, add your device... I just had to specify Name, Target, SD Card size.
Once I had done all these steps, I was ready to rock'n'roll. Once way to check that your device and your PC are talking to each other is to do the following:
  1. Open a console window
  2. Goto <android sdk>\platform-tools folder
  3. Run the following command: adb devices
You should see your device listed with some alphanumeric identifier assigned to it. If you dis-connect it from the USB port and run this command again, you should see that the device is no longer listed.

The next thing that I did was to create a Flex Mobile Project and just add a label to the UI and set its text property to "Hello World". Then I ran the application and voila, the application was compiled and auto-deployed and auto-launched on my device!

NOTE: Make sure that the Run Configuration has it's Launch Method set to On Device.

I hope these steps help out all those that are getting started in Android development with Flex!


Dreamweaver 5.5 is solid for HTML development

I recently upgraded to CS5.5 and I've been using Dreamweaver to build an HTML5/jQuery site with PHP on the server-side and I must say, it is one good product. It has everything you need a modern day development tool, from code-hinting (for HTML5 and PHP), to a design view (so you can see what you are building) and easy remote server synchronization.

Also, the CS5.5 release added much needed code-hinting for jQuery, one of the best JavaScript frameworks out there IMHO (I don't know where I'd be without it for JavaScript development). They have taken the jQuery support one step further and also added templates for jQuery Mobile, so you can use the framework to build mobile applications as fast as possible. There is further evidence of mobile development, in the way of support for CSS3 media queries and a magic "Multiscreen" button in the toolbar that allows you to preview what your page will look like on a phone, tablet or browser all in one go. Needless to say, Adobe has added some nice features to support current development trends.


Montreal AUG meeting June 1st

This upcoming Wednesday June 1st 2011, will be the first Montreal AUG meeting in a year. The event will be held at the Atwater Library (Google map details here) from 6:00 to 9:00 pm. You can find some details here. The primary presentation will be about the newly released Flex SDK 4.5 and Flash Builder 4.5, which will be given by Martin Arvisais, a Flex/Flash developer and trainer here in Montreal.

There is no need to sign up, you just need to show up and bring any friends/colleagues along with you. I will not be able to attend due to a prior commitment, otherwise I would have loved to give a presentation of my own.


HTML5 Development and Flash/Flex by Coenraets

Just saw a very nice presentation given by Adobe Evangelist Christopher Coenraets over at InfoQ. The presentation was mostly about doing HTML5 design/development with Adobe products such as Illustrator and Dreamweaver. He also shows how to test your site for browser compatibility (for layout specifically) using Adobe BrowserLab. He then shows off some experimental technologies, you will have to watch the video for what exactly and finishes off by demonstrating some cool Flex/AIR features using various tablet devices.

Very cool presentation indeed, so what are you still standing around here for, go watch it!


Adobe AIR 2.6 released

Adobe released yesterday AIR version 2.6 which contains numerous changes. One of the big things with this release is to bring back iOS support to AIR development. As you know there was a big hoopla last year about other development tools compiling for the iOS platform, well since the change late last year, companies like Adobe can again support iOS development (using AIR in this case) once again.

The biggest change that I see and welcome, cause I actually tried to do AIR development on my iPhone 4 late last year, is that the Packager for iPhone (PFI) is no more, the AIR Developer Tool (ADT) which comes standard with the AIR SDK, now handles the iOS platform as well; making it easier to package and deploy an application to an iOS device.

Of course there are numerous changes, and rather than me listing them all here, some other wonderful people have done that already, so there is a nice feature list (courtesy of Christian Cantrell) and quick video (by Ryan Stewart) showing off some of the new features.

You can download the Adobe AIR 2.6 SDK here and get the run-time here.


Flex is sexy

This week I got called into my President's office to talk about the new web application I've been building over the past few months. He wanted to comment on certain elements of the UI, some of which are little changes that totally make sense to me and that I will certainty do.

However he got me at the "it's not so sexy". He tried to explain it to me, but he couldn't find the correct words to express what he meant by that. So I tried to ask him various questions, such as: is it the colors? Do elements look floating in space? Are elements misaligned? And he would always answer with "it's not sexy". He then went about telling me how the first 9 children (applications) I had built were sexy and how this one was not. How it wasn't very Apple-like. Then it hit me, the first 9 applications are all Flex based! And this last one was purely done in HTML.

This reminds me of how the Flex engineers are always fond of saying how alot of Flex applications use the default theme, and that skinning is not done as often as they would like. Of course they were saying that about Flex when it was version 2/3, and hence we got version 4, were you can skin everything about it to your hearts content. Needless to say, I use the default theme, cause skinning is just not a priority for us.

So now I have to go make little visual changes, meaning make changes to the CSS, and possibly even add some gradients here and there to give it more umph! Not to say it's not possible, it totally is... just that... all this to say... with only that default theme... Flex is sexy :)


Molehill demo

Here is a demo of the 3D capabilities found in the Flash Player version codenamed "Molehill" (will this be in Flash Player 11 some day?). Actually the demo compares the performance of the "Molehill" APIs versus how things run in version 10 and it is impressive. Go check it out!

Flex testing frameworks

As we all know, creating applications is loads of fun, but since we are not perfect developers, we do tend to create applications with bugs in them (but you know, that doesn't happen often :) ). And because of that, we need to properly test our applications, including our Flex/AIR applications. I have mentioned various testing frameworks many times on my blog, but just came across this list of 10 unit testing frameworks with a brief description to each.

Not on this list if RIATest, an application used to perform recording and playback of Flex/AIR applications, which is what we use at my company.

In any case, research and use the one you fell is best for the job so that you can deliver the best applications out there!


Creating AIR applications using Google's GWT

Just saw this cool project on Flexcoders: gwt4air. Gwt4air is project that allows you to use Google's Web Toolkit (GWT) to build Adobe AIR applications without having to learn MXML or Actionscript at all. For myself personally this has never been a problem, as I am fond of saying, if you know Java, you know MXML and Actionscript. Mind you, there are some things to learn, that goes without saying when learning any new programming language, but the similarities between the two technologies is so similar that the learning curve is small.

But with gwt4air, that learning curve is further minimized, and this now becomes one of these easiest ways for someone to immerse themselves in Adobe AIR programming coming from a Java development background. Basically write some Java code and voila, an AIR application is born! Then once the programmer is comfortable with that, they can then take the next step of programming directly in MXML and Actionscript, using the compiler, etc... Just another great tool for a great technology I say :)

The Incubator

Adobe has a new thing over at the Labs web site: the Incubator. The Incubator contains pre-beta versions of the Adobe Flash Player and Adobe AIR. These versions are highly unstable, but do contain the latest cutting edge features that developers might want to play around with and get a glimpse into the far future and help mold it at the same time :) But it is important to remember that such features might never actually be included into any final release of these aforementioned products.

And just to give you an idea of what currently can be done with the Incubator version of the Adobe Flash Player (codenamed "Molehill"), check out these cool videos!


Looks like a great year for Flash in 2011

On the heals of the Flash Player 10.2 release, which includes great performance enhancements, 2011 seems to be a great year for Flash overall. With the increase in competitiveness between manufacturers in the mobile and tablet space, basically many new devices will include support for Flash, which is great news for content creators. You can basically create your content in one language/platform and have it delivered to many devices thus reaching millions of end-users.

There are a couple of short videos released today that describe this in numbers. Go here.


Flash Player 10.2 makes Linux users happy

With this week's release of Flash Player 10.2, Linux users are very happy. I was just over at my mom's, and my brother who uses Linux everyday for his school work, just upgraded to the latest version of the Flash Player and the speed improvement is noticeable. We were watching some YouTube videos with version 10.1 when I told him to upgrade to 10.2, and then we re-watched the same videos and you can definitely tell the difference. Especially in full screen mode, where before it was completely choppy and now playback is a lot smoother. It is still not as smooth as it can be, as I find the same videos still play better on Windows based PCs.

This is good news all round for the Linux community and also bodes well for mobile phones and tablets that run the Android OS.

If you run Chrome on Linux, you just need to update your Chrome to the latest 9.x release and it will include Flash Player 10.2. For those using FireFox, just download the latest Flash Player from Adobe's site and you are set!


Flash Player 10.2 now available

As of today, Flash Player 10.2 is available from Adobe. Below I've highlighted the main changes in this release, but you can read about them in full detail on this page.
  • Stage Video! Basically means full hardware acceleration for video playback on Windows and Mac (something that started back in version 10.1). Suppliers such as Vimeo and YouTube will be upgrading their content to take advantage of this feature.
  • Full screen support on multi-screen systems
  • Support for custom native mouse cursors
  • Text-rendering enhancements
  • Support for GPU rendering in upcoming IE 9
You can get it from their web site as always, but here is the directly link for anyone who needs it.


Optimize your app for Google TV

Was just reading an article about how Google is now providing an HTML5 and Flex 4.5 library to help build applications that will run better on Google TV. The library can be downloaded from the following location: http://code.google.com/p/gtv-resources/

From what I've read it seems that the library contains a set of components that are optimized and better suited for the Google TV experience. I haven't built any such applications myself, but if you have or are going too in the near future, I suggest you check it out!


Parsley Framework tips

As I have been using Parsley lately, thought I'd share a couple of tips. Here goes...

Selectors on result methods
When declaring the result method of your command class, it probably looks like this:

public function onResult( ... ):AsyncToken { ... }

That's nice, but if you have several commands classes in your project, Parsley will end up calling all of them once a remote method completes. You need to specify a selector which has the same event code as the associated event class in each command. So the above becomes:

public function onResult( ... ):AsyncToken { ... }

Global error handler
Following the same theme, for fault methods, you probably want to have a global one, so that you can display a uniform message when things go wrong. You can accomplish this by creating a class that has a single method with the following declaration:

public function handleFault( event:FaultEvent ):void { ... }

And then just declare it in your Parsley configuration file, like so:

<someNS:GlobalAlertHandler />

And finally, since this is not a Parsley feature directly, but a Cairngorm 3 add-on, you will need to download and include in your project the Cairngorm Integration Library, which you can get from here.

CloseEvent and PopUps
If you are using the Cairngorm PopUp Library, then careful when your popup MXML component is throwing the CloseEvent. Throwing this event will cause the popup to close, but if your MXML component is overriding the close handler, you won't get the result you expect!


Parsley Framework Basics

After studying the Parsley framework lately, I obviously decided to created a mini-application to learn the basics of how the framework operates. And I've decided to share that here. Some concepts like custom Events and Commands will seem familiar if you have used the Cairngorm framework in the past.

Note: Some code omitted for brevity.

Creating View and Presentation Model
Our mini-application will simply display a list of Contacts in a DataGrid that is loaded from a remote source. So needless to say, create an MXML file (Contacts.mxml) that contains a DataGrid control with appropriate settings. The next part is important...no Script blocks! The whole point of the Parsley framework is to put all UI business logic in Presentation Model class, so unit testing is easy.

So the next step is to create the Presentation Model class called ContactsPM. This class should extend EventDispatcher (to be explained later), have a bindable field called contacts of type ArrayList and contain an empty method called search()... like so:

public class ContactsPM extends EventDispatcher {
public var contacts:ArrayList;

public function search():void {}

The last part is to go back into your MXML view file (Contacts.mxml) and add two things. First, declare a bindable instance of the ContactsPM class you just created and also add the [Inject] metadata tag to it, like so:

public var model:ContactsPM;

The [Inject] metadata tag will be used by Parsley to set an instance of the class when the framework initializes. Secondly, bind the contacts field of the ContactsPM class to the dataProvider of the DataGrid, such that when the contacts are set, the DataGrid will display them. Example is as follows:

<mx:DataGrid dataProvider="{model.contacts}"/>

So far, we have setup our view to use our Presentation Model class to display a list of contacts. How this will actually happen, comes next.

Creating custom Event and Command
The next steps are much like what you would do if you were using the Cairngorm framework. We will dispatch an Event that will in-turn execute a Command to retrieve our contacts. And in the case of Parsley, this is easier cause there are no classes to extend or interfaces to implement (is this better or worse? for you to debate).

First, create the GetContactsEvent class that extends the Flex Event class and simply calls the super constructor with the event name to set. Like so:

public GetContactsEvent extends Event {
public function GetContactsEvent() {
super( "getContacts" );

Next we need to create the GetContactsCommand class. It must declare two injectable fields, one for the remote object to use and another for the Presentation Model class (ContactsPM) we created earlier. Again, Parsley will set the values on these fields when the Command class is initialized. Example:

[Inject] public var service:RemoteObject;
[Inject] public var model:ContactsPM;

Then we need our command class to declare two methods. First, the execute method that takes our event class as a parameter and calls the remote Java method (notice the [Command] metadata tag that tells parsley which method to call when the event is fired):

public function execute( event:GetContactsEvent ):AsyncToken {
return service.getContacts() as AsyncToken;

Secondly, a result method that takes an ArrayList as a parameter and sets it on our model so that the view will refresh itself (notice the [CommandResult] metadata tag that tells parsley which method to call once the remote call returns).

public function onResult( items:ArrayList ):void {
model.contacts = items;

Note: You can also declare a fault method for handling any failures.

Dispatching the Event
Now that we have created certain parts of our application, we need to connect them together, basically how to fire the command when our custom event is fired. Well remember the search() method in our Presentation Model class (ContactsPM) which we left empty earlier? Well time to fill it up with:

public function search():void {
dispatchEvent( new GetContactsEvent() );

Next, you need to add some metadata atop the ContactsPM class so that Parsley is aware that it will broadcast this event. This done by adding the following to the top of the class declaration:

[Event(name="GET_CONTACTS", type="demo.commands.GetContactsEvent")]
public class ContactsPM extends EventDispatcher {

The last thing to do is to call the search() method once a button is pressed, as an example. Because the ContactsPM class extends EventDispatcher and the metadata information that was just added, the dispatch() method will use Flex's internal event mechanism to fire the event and then Parsley will take of calling the appropriate method on the appropriate class - in this case the execute method in the command class.

Configuring Parsley
Now the last part of our exercise is to create our Parsley configuration so that it can properly initialize the classes we have created and make our application work.

Creating Parsley configuration file
Like in the world of Spring, we must create a configuration file were all the objects that we need Parsley to manage will be declared. This will be in done in a simple MXML file (ContactsParsleyConfig.mxml):

<Objects xmlns:fx="http://ns.adobe.com/mxml/2009"
<dom:ContactsPM />


<mx:RemoteObject id="contactManager" destination="contactManager"/>

The root tag of this MXML file is the Objects class that is defined by Parsley. Then we declare the Presentation Model class (ContactsPM), the command class (GetContactsCommand) and finally the RemoteObject class that the will be called by the command (in my demo it refers to a Java class).

Notice none of the declared objects have identifiers (id), but for such a small demo, this is not needed. More on that in future blog post :) .

Initializing Parsley
Now only two more changes remain to be done. In our root Application MXML file, we need to tell Parsley to load our configuration file. You do this by using Parsley's ContextBuilder tag as follows:

<s:Application xmlns:sf="http://www.spicefactory.org/parsley">
<sf:ContextBuilder config="ContactsParsleyConfig"/>

And the final change is to add a single tag to the view (Contacts.mxml) component created earlier to tell it that it is part of the Parsley setup and will need to configured by Parsley when initialized - remember the view has the Presentation Model class as an injectable property:

<mx:VBox xmlns:sf="http://www.spicefactory.org/parsley">
<sf:Configure />

And folks that's it. If anyone needs the actual demo source, please let me know and I will be happy to send them to you. I will be writing more about Parsley in the New Year as I learn more, with some some advanced posts and maybe some tips and tricks.

Until then, Happy New Year to all!