Hgroup - 如何更改元素的顺序?

时间:2011-05-11 13:07:29

标签: flex4

当我创建一个组并向其添加元素时,它会从左到右添加元素。

如何更改它以从右到左添加元素?

1 个答案:

答案 0 :(得分:5)

听起来你想要拥有与通常的MXML相同的控件和代码,但是从右到左的元素方向。因此,您需要Flex SDK 4.1及其布局镜像功能。您可以参考the documentation如何使用它。

这是快速示例代码:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"
    xmlns:s="library://ns.adobe.com/flex/spark">
    <fx:Script>
    <![CDATA[
        [Bindable]
        private var currentDirection:String = "ltr";
    ]]>
    </fx:Script>
    <fx:Declarations>
        <s:RadioButtonGroup change="currentDirection = selectorsGroup.selectedValue.toString()" id="selectorsGroup" />
    </fx:Declarations>
    <mx:VBox horizontalCenter="0" verticalCenter="0">
        <s:HGroup id="controls" layoutDirection="{currentDirection}">
            <s:Button label="1" />
            <s:Button label="2" />
        </s:HGroup>
        <s:HGroup id="selectors">
            <s:RadioButton group="{selectorsGroup}" label="LTR" selected="true" value="ltr" />
            <s:RadioButton group="{selectorsGroup}" label="RTL" value="rtl" />
        </s:HGroup>
    </mx:VBox>
</s:Application>