02
Oct
07

Positioning controls in Flex 3 using constraint columns

The following example shows you how to position controls on the display list using the <mx:ConstraintColumns /> and <mx:ConstraintColumn /> tags.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/10/02/positioning-controls-in-flex-3-using-constraint-columns/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:ApplicationControlBar dock="true">
        <mx:Form>
            <mx:FormItem label="col1 width:">
                <mx:HSlider id="slider1"
                        minimum="50"
                        maximum="250"
                        value="200"
                        liveDragging="true"
                        snapInterval="1"
                        tickInterval="20"
                        dataTipPrecision="0" />
            </mx:FormItem>
            <mx:FormItem label="col2 width:">
                <mx:HSlider id="slider2"
                        minimum="50"
                        maximum="250"
                        value="200"
                        liveDragging="true"
                        snapInterval="1"
                        tickInterval="20"
                        dataTipPrecision="0" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <mx:Canvas width="100%">
        <mx:constraintColumns>
            <mx:ConstraintColumn id="col1" width="{slider1.value}" />
            <mx:ConstraintColumn id="col2" width="{slider2.value}" />
        </mx:constraintColumns>

        <mx:Button label="OK" left="col1:0" right="col1:0" />
        <mx:Button label="Cancel" left="col2:0" right="col2:0"/>
    </mx:Canvas>

</mx:Application>

View source is enabled in the following example.

For more information on enhanced constraints in Flex 3, see “Flex 3 Details - Enhanced Constraints”.


3 Responses to “Positioning controls in Flex 3 using constraint columns”


  1. 1 Ian Ilsley Oct 3rd, 2007 at 9:11 am

    Great Article , however I’m having trouble with the stability of FlexBuilder3 B2 when using constraintRows/constraintColumns , have you tried adding more rows ? Once you get to
    approx 10 rows , FB3 will crash alot , the swf that is generatored runs really slowly also , eating cpu / memory .

  2. 2 peterd Oct 3rd, 2007 at 9:34 pm

    Ian Ilsley,

    This is probably one of the first times I’ve played with the new constraint rows and columns in Flex Builder 3. If you have a simple, reproducable test case, would you mind filing it in the public Flex Bugbase at http://bugs.adobe.com/flex/ and somebody at Adobe can investigate. (Also, post the bug number here if you don’t mind and I can try and push it through the queue a bit faster. Thanks.)

    Peter

  3. 3 Ian Ilsley Oct 7th, 2007 at 12:53 pm

    Hi Peter ,

    I’ve already logged a bug

    http://bugs.adobe.com/jira/browse/FB-9904

    thanks

    Ian

Leave a Reply

This blog is terrible at eating HTML tags. If you plan on posting code/XML, please escape your "<" characters as "&lt;" and your ">" characters as "&gt;".




Badge Farm

  • Firefox 2
  • Powered by Redoable 1.2
  • Feeds burnt by Feedburner
  • Feed