A simple solution for parallel development in Flex and Apollo

One of my first thoughts when Apollo came out was how to support parallel development. I would like to use Apollo to deploy my Flex applications on the web and as desktop applications. In this post I’ll show you a simple way to port your Flex application to Apollo.

Basically, the only difference between a Flex and an Apollo application is the root tag in the MXML, Application in Flex and ApolloApplication in Apollo (on a side note, if “Apollo” won’t be the official name of Apollo, is the API going to change, or will we have to live with the code name? Including specifics in an API is a typical architectural fallacy).

I have actually come up with two separate ideas on how to compile a simple Flex application as both a Flex compatible and an Apollo compatible SWF:

XSL

My first idea was to use XSL to transform the Flex application MXML to an Apollo MXML, but I decided it was a bit overkill. I’m still trying to find a good use case for XSL and MXML files – I know this is a solution looking for a problem, but it’s too interesting to ignore.

Refactoring

A better idea is to do some simple refactoring. What you do is that you change the Application tag in you main MXML to a Canvas tag, then you create two new files: “Application.xml” and “WebApplication.mxml” (or whatever you like). If your previous main MXML was called “Main.mxml” this is what the two new files should contain:

Flex

<Application
  xmlns="http://www.adobe.com/2006/mxml"
  xmlns:zm="*"
  width="100%"
  height="100%"
>
    <zm:Main/>
</Application>

Apollo

<ApolloApplication
  xmlns="http://www.adobe.com/2006/mxml"
  xmlns:zm="*"
  width="100%"
  height="100%"
>
    <zm:Main/>
</ApolloApplication>

Basically, you refactor your Flex application into a Flex component and use that component in both your Flex and Apollo applications.

Mind you, this tip is mostly useful when you want to have your application both on the web and be able to run it with Apollo. For applications that want to take advantage of the other things that Apollo offers, this is a little too simplistic.

I have some ideas in mind for how to support more complex variants of Flex-Apollo parallel development, but I’ll save them for a later post when I have thought them through and tested them out properly. Until then my tip is that you google for “dependency injection”.

6 Responses to “A simple solution for parallel development in Flex and Apollo”

  1. Maz Says:

    Thank you for that article. I was wondering about the same . In fact I hope there would be any update to the FlexBuilder to port easily a flex app to apollo and inversely. If you come up with a solution it would be a great idea to package it as an Elipse plugin ??

    Sorry I was daydreaming ;)

    {Maz}

  2. Theo Says:

    To port from Flex to Apollo everything you need is outlined above there is no need for a specific plug in to do this.

    To port from Apollo to Flex is another matter because Apollo has more features, such as file system access and offline support, so you have to make sure your architecture supports that. How to do this is another article, though.

  3. JabbyPanda Says:

    Flex SDK during alpha and beta stages has to be subject to the changes to the very extent.

    What I like about Flex API, that MXML abbreviation stays forever with us :) http://www.jabbypanda.com/blog/?p=13

  4. About Desktop Applications « It’s all about RIA Says:

    [...] Theo Hultberg :: A Simple Solution For Parallel Development In Flex And Apollo [...]

  5. Adobe AIR « Flex Generation Weblog Says:

    [...] Theo Hultberg :: A Simple Solution For Parallel Development In Flex And Apollo [...]

  6. Architectural Atrocities, part 11: Not yet another namespace construct / Iconara Says:

    [...] remember when AIR was called Apollo and the WindowedApplication class was called ApolloApplication. This is the same kind of [...]

Leave a Reply