Example AS3 Modular Application Using RobotLegs & Signals

Written by

How many of you Flex and ActionScript developers are architecting your applications in a modular fashion? By modules I mean compartmentalising specific application logic and not necessarily using Spark (or MX) modules. If I answer my own question I would say sporadically up until recently but now I approach project architecture in a modular based format with multi functional areas (thanks once again to @Stray_and_ruby for the heads up on this link).

If you clicked on the link above you will see a definition of modular as:

[Modular Architecture] Refers to the design of any system composed of separate components that can be connected together. The beauty of modular architecture is that you can replace or add any one component (module) without affecting the rest of the system. The opposite of a modular architecture is an integrated architecture, in which no clear divisions exist between components.

In reality when approaching your project it can be difficult to decide which logic should be separated out as a module, but I have found that the more you embark on the modular route the easier this decision becomes, there is no hard and fast rule to follow. I will not go into specific benefits in using a modular approach in Flex/ActionScript development as there are plenty of articles on the internet, if you would like an introduction into Flex modules and RobotLegs then read Joel’s informative post.

The example I built is on GitHub as a repository named AS3ModularRobotLegsExample and has a README detailing all the necessary information to get you up and running, including all the links to the required libraries etc.

I have used both Modular utilities on RobotLegs applications and both have their merits, however, I primarily started using the utilities in Flex applications with the latest versions of RobotLegs and As3 Signals so settled on Joel’s fork. After using that particular fork in Flex applications with no issues, I was concerned that there would be potential obstacles using it in a pure AS3 project as it appeared from the example geared towards Flex Modules. It works absolutely fine though but there are slight changes in the example Joel provides hence my creating the AS3ModularRobotLegsExample.

After reading around the links I provided above I think the main areas to familiarise yourself within the example would be the module loading logic therefore I recommend looking at the unit tests:

As I stated in the README my chosen approach to module loading is one of many and mine is not necessarily the optimal method.

I am now working on a Flex 4.5 example and how to use Gator to generate the project as whole to save having to build this core logic manually plus the classes and corresponding Unit Tests.