Your FLEXible friend

For the last 3 months I have been using Adobe FLEX to develop a front end for the Obesity eLab.  Now, I don’t want to get into discussions about the rights and wrongs of RIAs etc. but just thought I would pass on a few interesting FLEX/Flash/Actionscript things I have found out during this coding voyage.

  • Remember your Cross Domain policy or your client will not be able to talk to your server
  • When adding custom MXML modules programatically there is no guarantee that any of the components inside will exist.  Can lead to lots of annoying null pointer exceptions.  You might have to check that they are not null and create them in actionscript.  I have found that doing something with the parent module eg. adding to a tab navigator forced the child components into life.  Setting the creationPolicy to ALL seems to have no affect.  I look forward to finding out the correct way to do this because I have found little to help on the web.
  • When downloading files using FileReference you have to add an event listener to handle the IOErrorEvent.IO_ERROR or else you get a #2038 IO Error
  • To add an icon to a button that has been created in ActioScript you have to declare the icon you want to use like this:
  1. [Embed(source='/assets/analysis_small.png')]
    [Bindable]
    private var analysisImage:Class;
  2. Assign using code: analysisButton.setStyle(“icon”, analysisImage);
  • Events seem to pass from child to parent but not the other way.  When adding event listeners you need to add them to the level above the originator of the event.  Has meant all sorts of weird things like systemManager.addEventListener and Application.application.addEventListener.  Now, I might be getting this wrong but no amount of googling has led to a sensible answer.

Overall, FLEX seems great for UIs which are not reacting to data changes but needs a bit of tweeking by Adobe to make it a real power users language of choice.  Doing things like grids which react to check box clicks needs quite a bit of code.  There also seems to be some fundamental UI components missing eg. dockable drag and drop panels.  Sure, there is usually some open source solution available or you can write your own but it would be nice if the core API had these things.