Posts Tagged ‘mxml’

Avoid the Monolithic Application File: Modularize Your MXML

Wednesday, December 5th, 2007

One of the best things you can do to make your application code in Flex more readable is to modularize the code. What I mean is, try to break things down into separate components. If you need to get data from these components, then expose public read-only properties. Add events so you can respond to things such as click events. This seems like a little extra effort, but really it is far easier to edit several components than to work on one monolithic MXML Aplication file. Learning how to properly create and use custom MXML components will add a little time to the visual design-time of your application, but when it comes to the code-behind it will be easier to separate logic and avoid monster MXML files with dozens of <mx:AddChild> tags for when you switch states. Instead, simply add only a specified custom component to your application file and your MXML and ActionScript is able to remain clean.

I would have to say that it may be even worth going back and modularizing existing code because the increase in ease when you begin to code ActionScript is that worth it.