Flex4 spark panel 布局

本文介绍了一个使用Adobe Flex框架实现的动态布局切换示例。通过下拉列表选择不同的布局类型(垂直、水平或瓷砖布局),并实时应用于Spark Panel容器中。此示例展示了如何根据用户的选择动态更改UI布局。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/02/18/setting-the-layout-direction-on-a-fxpanel-container-in-flex-gumbo/ -->
<s:Application name="Spark_Panel_layout_test"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo">

<fx:Script>
<![CDATA[
import spark.layouts.supportClasses.LayoutBase;
import mx.events.IndexChangedEvent;
import spark.layouts.*;

protected function dropDownList_selectionChanged(evt:IndexChangedEvent):void {
var panelLayout:LayoutBase;
switch (dropDownList.selectedItem) {
case "VerticalLayout":
panelLayout = new VerticalLayout();
break;
case "HorizontalLayout":
panelLayout = new HorizontalLayout();
break;
case "TileLayout":
var tileLayout:TileLayout = new TileLayout();
tileLayout.requestedColumnCount = 3;
panelLayout = tileLayout;
break;
default:
panelLayout = new BasicLayout();
break;
}
panel.layout = panelLayout;
}
]]>
</fx:Script>

<mx:Form>
<mx:FormItem label="layout:">
<s:DropDownList id="dropDownList"
requiresSelection="true"
selectionChanged="dropDownList_selectionChanged(event);">
<s:dataProvider>
<s:ArrayList>
<fx:String>VerticalLayout</fx:String>
<fx:String>HorizontalLayout</fx:String>
<fx:String>TileLayout</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:DropDownList>
</mx:FormItem>
</mx:Form>

<s:Panel id="panel"
title="I'm a Spark Panel title"
horizontalCenter="0"
verticalCenter="0">
<s:layout>
<s:VerticalLayout />
</s:layout>
<s:Button label="One" />
<s:Button label="Two" />
<s:Button label="Three" />
<s:Button label="Four" />
<s:Button label="Five" />
</s:Panel>

</s:Application>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值