tags:

views:

191

answers:

2

hi all:

i want use two button to control list turn left/right one element.

but i got some confuse about how to layout those component.

i use " requestedColumnCount="6" " to set the list width , so in the design model

i only know this list can display 6 element , but i don't know how width it will be.

so i use the "HGroup" to set the layout , the main code is like this way

<s:HGroup x="214"
    y="216">
 <s:Group>
  <s:layout>
   <s:VerticalLayout />
  </s:layout>
  <s:Button label="←"
      click="button1_clickHandler(event)"/>
 </s:Group>
 <s:Group>
  <component:SmoothScrollingList dataProvider="{myProvider}"
            itemRenderer="myitemdrender.FriendPageItemRender"
            id="friendPageList"
            mouseDown="friendPageList_mouseDownHandler(event)">
   <component:layout>
    <s:HorizontalLayout requestedColumnCount="6"
         useVirtualLayout="true"/>
   </component:layout>
  </component:SmoothScrollingList>
 </s:Group>
 <s:Group>
  <s:Button label="→"
      click="button2_clickHandler(event)"/>
 </s:Group>
</s:HGroup>

you can see i use one HGroup and three group to determine where the component should be.

is almost finish , but i still got problem about how to set those two button at the

middle of the position?

i try to use

  <s:layout>
   <s:VerticalLayout horizontalAlign="center"/>
  </s:layout>

in the first group layout , but seem not working.

and my another question is :

is this a good way to use so many group and hgroup to determine the position ? is there

have any other good way to do it ?

thanks a lot.

A: 

You should use attributes in those cases, to clean the code a bit more up; then it is also visible where such additional attributes belong to. For example for the first group, just write:

<s:Group layout="VerticalLayout">
    <s:Button label="←" click="button1_clickHandler(event)"/>
</s:Group>

However in your case it makes less sense to use an additional Group element for just one different element inside.

<s:HGroup x="214" y="216" verticalAlign="middle">
    <s:Button label="←" click="button1_clickHandler(event)"/>
    <component:SmoothScrollingList
            id="friendPageList" dataProvider="{myProvider}"
            itemRenderer="myitemdrender.FriendPageItemRender"
            mouseDown="friendPageList_mouseDownHandler(event)">
        <component:layout>
            <s:HorizontalLayout requestedColumnCount="6" useVirtualLayout="true"/>
        </component:layout>
    </component:SmoothScrollingList>
    <s:Button label="→" click="button2_clickHandler(event)"/>
</s:HGroup>
poke
sorry about the mess code . i will pay attention next time T_Tand about use three group<s:HGroup> <s:Group/> // Button ← <s:Group/> // List <s:Group/> // Button →</s:HGroup> beacuse i want make the component just in the middle of the list.ex: list heiht = 100, then the first button position should be (0,50) but for now the position of fisrt button is (0,0).i try to use <s:Button top=50%> but it's doesn't work , it's only work when i set the exact value like : <s:Button top="45">.
Tunied
Well, the HGroup should automatically distribute all child elements in the horizontal plane. The `verticalAlign="middle"` should then put all elements in the middle *of the HGroup's height* (so it could be that the HGroup is just not high enough to distribute it to the mid).I don't have Flex 4 installed yet, so I can't test it myself, but HGroup, being the equivalent of HBox in Flex 3, should work like this.
poke
A: 

Sorry , maybe my describe is not very clear.

my gold is may some Ui like this one( http://i46.tinypic.com/2nbbxc4.jpg ).

but in the degin model i don't know how heiht/with dose the list will be. and i want the

button is 30% of the list height. i try to use one HGroup contain all 3 componet.

seem not working.

<s:HGroup x="214" y="216" id="parentGroup">
    <s:Group id="childOneGroup">
     <s:Button label="←" top="{parentGroup.height*0.3}"/>
    </s:Group>
    <s:Group>
     <component:SmoothScrollingList dataProvider="{myProvider}"
        itemRenderer="myitemdrender.FriendPageItemRender"
        id="friendPageList">
      <component:layout>
       <s:HorizontalLayout requestedColumnCount="6" useVirtualLayout="true"/>
      </component:layout>
     </component:SmoothScrollingList>
    </s:Group>
    <s:Group>
     <s:Button label="→" top="30"/>
    </s:Group>
</s:HGroup>

but if i use three group(each compont belong to one ) and change th button " top "

value to {parentGroup.height*0.3} ,it's working.

Tunied