flex spaghetti

Just another WordPress.com weblog

Setting the layout property in Flex 4

Posted by rvollmar on June 13, 2009

In Flex 3, the layout property could be set to strings such as “absolute”, “horizontal”, and “vertical”. In Flex 4, the layouts are classes such as BasicLayout, HorizontalLayout, VerticalLayout, and TileLayout. If you try to set the layout property in a class’ MXML tag, you will get the compiler error “values of type spark.layouts.supportClasses.LayoutBase cannot be represented in text.” Here are some options:

1. To set the layout for the Application in MXML:

<s:Application ...>
    <s:layout>
        <s:VerticalLayout />
    </s:layout>
...

2. To set the layout for a Group:

<s:Group>
    <s:layout>
        <s:VerticalLayout />
    </s:layout>
...

3. That seemed verbose, so there’s a shortcut to set the layout for a Group; you can use VGroup and HGroup:

<s:VGroup>
...

Enjoy,
– Rob

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: