<?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经典例子(二)----DataGroup(包含ItemRenderer重构及特效)
热度:44 发布时间:2024-01-16 18:55:50.0
相关解决方案
- Flex xml xmllist 有关问题
- Flex 函数写法解析,该如何处理
- flex-java 怎么让两个同时执行的事件有执行顺序
- Flex blazeds 跟 Hibernate延迟加载失效
- flex 3.0视频制作解决方法
- Flex 有关问题求解
- anyone would like to use Flex and CF together?解决思路
- anyone would like to use Flex and CF together?该怎么解决
- flex 配置https协议有关问题
- Flex 动态设立 Skin 、Style
- Flex SDK 引见
- Flex PopUpManager 弹出窗口正中
- Flex 加载资源、Skin 等资料,并动态生成对象
- Flex 图片压缩、下传
- Flex 测试项目,图片压缩、下传、图片裁剪,Module测试,国际化
- Flex 的数据绑定察看
- Flex , Flash Swc资料与Swf文件的关系和使用
- flex 结合 tomcat 问题~~~求助!!!!!
- flex 和spring 整合问题
- Flex: 新建mxml application无法自动生成HTML?
- flex 设置选中文本的颜色
- flex viewstack有关问题
- flex 怪怪的错,请进来看一眼感谢.解决思路
- flex~和ajax的区别哦解决办法
- Flex: 新建mxml application无法自动生成HTML?解决方法
- Flex: 新建mxml application没法自动生成HTML
- flex image mouseover有关问题
- Flex builder与eclipse整合有关问题,紧急
- 关于as3性能的有关问题 Flex
- Flex 虚拟社区开发,该如何处理