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

<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:

    <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>
Share

Comments (2)

Paul TaylorJune 16th, 2009 at 3:09 pm

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.

[...] Migrating From Flex 3 to Flash Builder 4: Nonvisual Classes in MXML Migrating From Flex 3 to Flash Builder 4: mx.core.Application var a2a_config = a2a_config || {}; a2a_config.linkname="Migrating From Flex 3 to Flex 4"; a2a_config.linkurl="http://unitedmindset.com/jonbcampos/2010/05/25/migrating-from-flex-3-to-flex-4/"; May 25th, 2010 in Development | tags: fx3, fx4, migrating [...]

Leave a comment

Your comment