Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex Flex VerticalLayout HorizontalLayout基于状态的元素顺序_Apache Flex - Fatal编程技术网

Apache flex Flex VerticalLayout HorizontalLayout基于状态的元素顺序

Apache flex Flex VerticalLayout HorizontalLayout基于状态的元素顺序,apache-flex,Apache Flex,在我的mxml部分,我有 <s:layout.landscape> <s:HorizontalLayout /> </s:layout.landscape> <s:layout.portrait> <s:VerticalLayout /> </s:layout.portrait> 例如,在这些标记之后,我有两个组件 <s:Button label="button 1"/> <

在我的mxml部分,我有

    <s:layout.landscape>
    <s:HorizontalLayout />
</s:layout.landscape>

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

例如,在这些标记之后,我有两个组件

<s:Button label="button 1"/>
<s:Button label="button 2"/>

我想做的是,一旦进入纵向或横向状态,就更改这些组件的顺序。例如,在纵向中,我有垂直布局按钮1,然后是按钮2
在景观中,我有一个水平布局,按钮2后面跟着按钮1。

你可以使用
这个。swapElements(按钮1,按钮2)

例如:-

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               minWidth="955" minHeight="600" currentState="landscape">
    <s:states>
        <s:State name="landscape"/>
        <s:State name="portrait"/>
    </s:states>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import spark.events.IndexChangeEvent;


            protected function dropdownlist1_changeHandler(event:IndexChangeEvent):void
            {
                // TODO Auto-generated method stub
                if(event.target.selectedIndex == 0)
                {
                    this.currentState = event.target.dataProvider[0];
                    this.swapElements(button1,button2);
                }
                else
                {
                    this.currentState = event.target.dataProvider[1];
                    this.swapElements(button2,button1);
                }
            }
        ]]>
    </fx:Script>

    <s:layout.landscape>
        <s:HorizontalLayout />
    </s:layout.landscape>

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

    <s:DropDownList selectedIndex="0" change="dropdownlist1_changeHandler(event)">  
        <s:ArrayCollection>
            <fx:String>landscape</fx:String>
            <fx:String>portrait</fx:String>
        </s:ArrayCollection>
    </s:DropDownList>

    <s:Button id="button1" label="button 1"/>
    <s:Button id="button2" label="button 2"/>

</s:Application>

景观
肖像

希望这可能会有帮助……

我认为您必须使用数据组。这样您就可以对数据提供程序进行排序。