My love for Flex grows more and more each day. I just found a super useful mxml tag that will save me (and you) a lot of work down the road.
Have you ever wished that you could quickly create a component without having to structure a proper class file? Not needing to plugin associated events, methods and any other internal mechanisms to get it to function with other classes or views?
If you can answer ‘yes’ to that question, then you might wanna take a look at the
mx:Component tag. It is a special mxml tag that allows you to set up a component (so far just itemRenderers and itemEditors) inline without all the associated overhead with creating a new class. Much like a helper class inside an actionScript file, you can define a component within another component. You can read more here.
One thing to note: The scope of
this between the
<mx:Component> tags will refer to the component itself and not the actual class it resides in. Another thing is that you can define an additional
<mx:script> tag inside the component. Of course one might debate then you might as well make it a real class.
Obviously you would move this inline-component over to an actual class if it became needed else where, but for rapid development in adding simple controls as itemRenderers/itemEditors this is a sure-fire way to go. I am not sure how long this puppy has been around (and I am sure someone will comment ‘I have been using this since Flex 1.5’) but I just found it and I love it!