6 Replies Latest reply on Jun 14, 2011 2:18 AM by CleanCoder

    constraint-based layout with group in actionscript

    ChristophFlex

      Hi,

       

      i need a constraint-based layout in Actionscript, this example works fine:

       

      <s:Group width="100%" height="100%">
           <s:layout>
                <s:FormItemLayout>
                     <s:constraintRows>
                          <s:ConstraintRow id="row1" />
                          <s:ConstraintRow id="row2"/>
                          <s:ConstraintRow id="row3"/>
                     </s:constraintRows>
                </s:FormItemLayout>
           </s:layout> 
           <s:Label text="row1" bottom="row1:0" />
           <s:Label  text="row2" bottom="row2:0" />
           <s:Label text="row3" bottom="row3:0"/>
                
      </s:Group>
      
      

       

       

      but i cant get it running in ActionScrip:

       

      var group:Group=new Group();
      var form:FormItemLayout=new FormItemLayout();               
      var vec:Vector.<ConstraintRow> = new Vector.<ConstraintRow>();
                     
      var row:ConstraintRow=new ConstraintRow();
      row.id="row1";
      vec.push(row);
                     
      row=new ConstraintRow();
      row.id="row2";
      vec.push(row);
                                                   
      row=new ConstraintRow();
      row.id="row3";
      vec.push(row);
                     
      form.constraintRows=vec;
      group.layout=form;     
                     
      var l:Label=new Label();
      l.text="hello";
      l.bottom="row1:0";
      group.addElement(l);
                     
      l=new Label();
      l.text="hello";
      l.bottom="row2:0";
      group.addElement(l);
                     
      l=new Label();
      l.text="hello";
      l.bottom="row3:0";
      group.addElement(l);
                     
      this.addElement(group); 
      
      

       

       


      i dont even see the labels with this code. what am i doing wrong?

       

      thank you for your help!