Migrating From Flex 3 to Flash Builder 4: Nonvisual Classes in MXML
In Flex 3 it was common for you the programmer to include nonvisual classes in mxml, such as controller class, front controllers (Cairngorm), event maps (Mate), Application Facade (PureMVC), validators, and other classes. The problem is, have you tried to include one of these classes as MXML in Flex 4? No, well let me tell you what happens, you get an error that says you can’t include nonvisual components. So what do you do with your existing applications that rely on these classes?
Flex 4 includes a new tag
1 2 3 | <fx:Declarations> </fx:Declarations> |
With this new section it allows you to throw in all of your nonvisual classes in MXML just the same way you used to in Flex 3. Congrats, I will now return you to your regularly fun Flexing.
Example:
1 2 3 4 5 | <fx:Declarations> <!--validations--> <mx:StringValidator id="v1" source="{input1}" property="text" minLength="24"/> <mx:StringValidator id="v1" source="{input2}" property="text" minLength="10"/> </fx:Declarations> |



It’s rare that I write non-visual classes in MXML. My AppFacade is never MXML. Shoot, I prefer to write even my visual components in ActionScript.