Modules don’t extend Application, but rather Module, which is basically a Container. As such, you can’t “preview” modules in Flex Builder like you can Applications. You instead have to load them into a ModuleLoader. A ModuleLoader has to then be placed in at least an Application container. Therefore, you can’t really develop with Modules in Flex without using Ant. You can, but it sucks.
Ant, the build automation tool that comes with Eclipse, allows you to define a bunch of XML tags that encapsulate a task. A task can “compile my module” and “compile my app” as well as “launch my app”. You then chain them together in an uber task like “compile my module, compile my app, launch my app”, all with 1 click. Dope.
Although Ant comes with Eclipse, it doesn’t come all mxmlc friendly. The free Flex compiler, mxmlc, unfortunately is usually launched via the exec tag in Ant. While Ant is nice in that it comes with simple tags, thus making it easy to read and learn, anything complicated is extremely frustrating. Combined with compiler parameters, linked tasks and resource files, this spirals out of control pretty quickly. Not to a Java developer mind you, just me.
Thankfully, Adobe has provided some Flex specific Ant tasks which you can get at the labs. Rad.
They didn’t work for me. Got weird errors. Problem? I’m a PC user, not a Mac user. However, I take my Macbook with me on client visits to force myself to learn it. Nothing like trial by fire I say. Long winded way of saying that spaces in your directories cause weird problems. In this case, the compiler will spit out this error:
[mxmlc] command line: Error: default arguments may not be interspersed with other options
Which is totally off base of what the real problem is. Thankfully, Google pointed me here.
While I like how Ant works out of the box, and requires no configuration on my part with regards to the Flex Ant tasks (copy a jar, reboot Eclipse, copy files, mod provided build script)… it doesn’t scale well with customizations. While the Java kids have moved onto Maven, I’ve had it with XML coding. While Ant is doing a pretty good job at code generating my Cairngorm event, command, delegate, callback, and test cases per use case, build wise it just isn’t “easy” to do builds the way I want to.
For example, some of my past build scripts with Flashcom (Flash Media Server) projects have involved an Ant build launching a Zinc wrapper SWF that did advanced build tasks. Ant’s build.xml files are nice if I need to tweak a build script; I can do so right from Eclipse in a text editor whereas my SWF uber-builders have to be “recompiled in Flash, and then post-processed in Zinc”. Sounds complicated, but it’s not. Code JavaScript ‘esque code, compile, and I have a fully customized build.
Anyway, I’m this close to just demanding the next developer who inherits my code base deal with the fact I’ve implemented Rake (Ruby’s version of Make) as the standard build environment, even if it’s not the best in working with Eclipse.
Bottom line, if someone utilized that new Java 6 feature, and wrote a JavaScript based build library, it’d be the coolest thing on the planet.
…well, next to Bruce Campbell of course.