flex4 实现左右移动效果

本文展示了一个使用Flex进行XML数据处理的应用实例。通过Tree组件选择产品类别并添加到List中,实现从XML数据源到用户界面的数据绑定及操作。该应用包括了数据绑定、XML解析和动态数据更新等功能。

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

<?xml version="1.0"?>
<!-- dpcontrols\XMLListCollectionWithList.mxml -->
<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"
			   width="550">    
	
	<fx:Script>
		<![CDATA[
			import mx.collections.XMLListCollection;
			import mx.collections.ArrayCollection;
			
			/* An XML object with categorized produce. */
			[Bindable]
			public var myData:XML=
				<catalog>
				  <category name="Meat">
					  <product name="Buffalo"/>
					  <product name="T Bone Steak"/>
					  <product name="Whole Chicken"/>
				  </category>
				  <category name="Vegetables">
					  <product name="Broccoli"/>                         
					  <product name="Vine Ripened Tomatoes"/>
					  <product name="Yellow Peppers"/>
				  </category>
				  <category name="Fruit">
					  <product name="Bananas"/>
					  <product name="Grapes"/>
					  <product name="Strawberries"/>
				  </category>
			  </catalog>;
			
			/* An XMLListCollection representing the data
			for the shopping List. */
			[Bindable]
			public var listDP:XMLListCollection = new XMLListCollection(new XMLList());
			
			/* Add the item selected in the Tree to the List XMLList data provider. */
			private function doTreeSelect():void {
				if (prodTree.selectedItem)
					listDP.addItem(prodTree.selectedItem.copy());
			}
			
			/* Remove the selected in the List from the XMLList data provider. */
			private function doListRemove():void {
				if (prodList.selectedItem)
					listDP.removeItemAt(prodList.selectedIndex);
			}
		]]>
	</fx:Script>
	
	<s:HGroup>
		<mx:Tree id="prodTree" dataProvider="{myData}" width="200"
				 showRoot="false" labelField="@name"/>           
		<s:VGroup>
			<s:Button id="treeSelect" label="Add to List"
					  click="doTreeSelect()"/>
			<s:Button id="listRemove" label="Remove from List"
					  click="doListRemove()"/>
		</s:VGroup>         
		<s:List id="prodList" dataProvider="{listDP}" width="200"
				labelField="@name"/>        
	</s:HGroup>
</s:Application>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值