Tour de Flex经典例子(二)----DataGroup(包含ItemRenderer重构及特效)
2012-09-14 18:47
357 查看
<?xml version="1.0" encoding="utf-8"?> <!-- Simple example to demonstrate a DataGroup with a virtualized layout. Written by Flex 4 Team --> <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[ import mx.collections.ArrayCollection; import skins.TDFPanelSkin; public function generateDataProvider(nItems:int = 10000):ArrayCollection { var ac:ArrayCollection = new ArrayCollection(); var sources:Array = ['San Francisco', 'New York', 'Vancouver', 'Denver', 'Hong Kong']; var destinations:Array = ['London', 'Houston', 'Orlando', 'Los Angeles', 'Seattle']; var airlines:Array = ['Green Jet', 'Orange Jet', 'Yellow Jet', 'Blue Jet', 'Red Jet']; var dates:Array = ['March 23-29', 'April 23-29', 'May 1-3', 'May 10-13', 'June 6']; // create a collection of random flights for (var i:int = 0; i < nItems; i++){ var temp:Object = new Object(); var random:int = Math.random() * 5; temp.start = sources[random]; temp.end = destinations[random]; temp.details = dates[random] + ', ' + airlines[random] + " (Flight " + i + ")"; ac.addItem(temp); } return ac; } ]]> </fx:Script> <s:Panel title="DataGroup with Virtual Layout" width="100%" height="100%" skinClass="skins.TDFPanelSkin"> <s:Scroller horizontalCenter="0" top="10"> <s:DataGroup width="600" height="123" clipAndEnableScrolling="true" dataProvider="{generateDataProvider(9000)}"> <s:layout> <s:VerticalLayout gap="1" useVirtualLayout="true" /> </s:layout> <s:itemRenderer> <fx:Component> <s:ItemRenderer width="600" height="20"> <s:states> <s:State name="normal" /> <s:State name="hovered" /> <s:State name="selected" /> </s:states> <fx:Script> <![CDATA[ override public function set data(value:Object):void { super.data = value; if (data == null) // a renderer's data is set to null when it goes out of view return; txtStart.text = data.start; txtEnd.text = data.end; txtDetails.text = data.details; } ]]> </fx:Script> <s:transitions> <mx:Transition fromState="normal" toState="hovered"> <s:Animate target="{flightPlan}" duration="200"> <s:SimpleMotionPath property="width" /> </s:Animate> </mx:Transition> <mx:Transition fromState="hovered" toState="normal"> <s:Animate target="{flightPlan}" duration="200" > <s:SimpleMotionPath property="width" /> </s:Animate> </mx:Transition> </s:transitions> <s:Rect left="0" right="0" top="0" bottom="0" radiusX="5" radiusY="5"> <s:fill> <s:SolidColor color="#E1ECF4" /> </s:fill> </s:Rect> <s:HGroup verticalAlign="middle"> <s:Group id="flightPlan" height="20" width="300" width.hovered="330"> <s:Rect left="0" right="0" top="0" bottom="0" radiusX="5" radiusY="5"> <s:fill> <s:SolidColor color="#65A3CE" color.hovered="#65A3FF" /> </s:fill> </s:Rect> <s:Label id="txtStart" color="#FFFFFF" fontWeight="bold" left="20" verticalCenter="2" /> <s:Label id="txtEnd" color="#FFFFFF" fontWeight="bold" right="20" verticalCenter="2" textAlign="right" /> </s:Group> <s:Label id="txtDetails" color="#32353f" fontSize="11" /> </s:HGroup> </s:ItemRenderer> </fx:Component> </s:itemRenderer> </s:DataGroup> </s:Scroller> <s:Label width="90%" horizontalCenter="0" color="#323232" bottom="40" text="Flex 4 DataGroups support virtualization. Virtualization is an optimization for layout and rendering that reduces the footprint and startup time for containers with large numbers of items. This sample shows how virtualization can be achieved by only creating enough objects for the items currently being displayed. The useVirtualLayout property should be set on the layout object to achieve virtualization."/> </s:Panel> </s:Application>
相关文章推荐
- Tour de Flex中经典例子(一)-------LinkBar与Viewstack实现导航
- Tour de Flex经典例子(三)------SkinnableContainer(登陆界面)
- flex4:中DataGroup组件获取数据源(ArrayCollection方式)实例
- Flex:List/DataGroup 去掉item选中时的默认的颜色
- 经典的OGRE机器人的例子(通过例子总结,包含四元数和动画等用法)
- 个人收藏的flex特效网址【经典中的极品】
- Flex 4中组件背景设置(填充方式)group为例子
- Flex 4中组件背景设置(填充方式)group为例子
- Developer Connection: Tour de Flex
- FLEX中自定义timer和DataTimer的例子
- Flex中给Tool tips添加一个很Cool的动画特效的例子源码
- 个人收藏的flex特效网址【经典中的极品】
- Flex中通过creationCompleteEffect样式为Accordion容器设置创建完成特效的例子
- 好东西!Tour de Flex component explorer
- Flex中如何通过监听itemClick事件检测FlexRadioButtonGroup中RadioButton被点击的例子
- Flex经典例子汇总 ------ 持续更新中
- 个人收藏的flex特效网址【经典中的极品】
- map集合最经典的编程例子(包含重写equals和hashcode,toSting)
- Flex: DataGroup 组件增加滚动条
- Flex经典例子 -- 产生一定限制的随机数