View Full Version : Extending MXML Best Practices

05-14-2009, 04:23 PM
I was wondering what the 'best' way is to extend an MXML component from a style point of view. For example, if I want to extend TitleWindow to do some shtuff, I feel like things get a bit cluttered when I add the mx:Script tags and fill it with the logic that runs the TitleWindows actions. Should I extend the MXML component with an AS class for the code? Is placing the code within the script tag the best way? Any alternate ideas? Just wondering, wanna keep my room clean. Thanks!

05-14-2009, 06:16 PM
IMO: only extend AS classes with MXML, but not MXML with AS or other MXML. This is because the actual MXML code is a bad AS code, it has lots of redundant stuff.
If you don't like putting the code in MXML, then extend the AS component, that that MXML component extends and modify it in AS, but, even though extending MXMLs is possible, you'll be very much limited in what you can do, you'll loose metadata (think styles, [DefaultProperty], [DefferedInstance], etc will not be inherited, no constructor arguments, or only default arguments etc...

05-14-2009, 07:12 PM
Cool, I do see where MXML extends MXML is kinda screwy. I'm trying to combine a few controls in a collection, creating its own component. I'll try marking it up as mxml and extending some controls and see how it goes. Thanks for your advice!