| <?xml version="1.0" encoding="utf-8"?> |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
| --> |
| <s:Group |
| xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:mx="library://ns.adobe.com/flex/mx" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| xmlns:assets="assets.*" |
| initialize="doInitialize()"> |
| |
| <fx:Script> |
| <![CDATA[ |
| |
| import flash.events.Event; |
| import mx.collections.*; |
| import mx.collections.errors.*; |
| import mx.events.CollectionEvent; |
| |
| public function doInitialize():void{ |
| items1.reset(); |
| } |
| |
| public function pendingFunction(i:int, obj:Object):Object{ |
| return {info: "item " + i.toString() + " pending", status: "pending"}; |
| } |
| |
| public function pendingFunction2(i:int, obj:Object):Object{ |
| return {info: "item " + i.toString() + " really pending", status: "pending"}; |
| } |
| |
| public function pendingFunction3():Object{ |
| return {info: "No params", status: "pending"}; |
| } |
| |
| public function pendingFunction4(i:int):Object{ |
| return {info: "One param", status: "pending"}; |
| } |
| |
| public function pendingFunction5(s1:String, s2:String):Object{ |
| return {info: s1 + " " + s2, status: "pending"}; |
| } |
| |
| public function pendingFunction6(i:int, obj:Object):void{ |
| // No return value |
| } |
| |
| // Used for states. |
| public function pendingFunction7(i:int, obj:Object):Object{ |
| return {info: "7: item " + i.toString() + " pending", status: "pending"}; |
| } |
| |
| public function errorFunction(i:int, obj:Object):Object{ |
| return {info: "item " + i.toString() + " failed", status: "failed"}; |
| } |
| |
| public function errorFunction2(i:int, obj:Object):Object{ |
| return {info: "item " + i.toString() + " totally failed", status: "failed"}; |
| } |
| |
| public function errorFunction3():Object{ |
| return {info: "No params", status: "failed"}; |
| } |
| |
| public function errorFunction4(i:int):Object{ |
| return {info: "One param", status: "failed"}; |
| } |
| |
| public function errorFunction5(s1:String, s2:String):Object{ |
| return {info: s1 + " " + s2, status: "failed"}; |
| } |
| |
| public function errorFunction6(s1:String, s2:String):void{ |
| // No return value |
| } |
| |
| // Used for states. |
| public function errorFunction7(i:int, obj:Object):Object{ |
| return {info: "7: item " + i.toString() + " failed", status: "failed"}; |
| } |
| |
| public function theObjectFactory(i:int):Object{ |
| return {info: "item " + i.toString() + " present", status: "present"}; |
| } |
| |
| public function theObjectFactory2(i:int):Object{ |
| return {info: "theObjectFactory2 item " + i.toString() + " present", status: "present"}; |
| } |
| |
| ]]> |
| </fx:Script> |
| |
| <s:states> |
| <s:State name="state1" /> |
| <s:State name="state2" /> |
| <s:State name="state3" /> |
| <s:State name="state4" /> |
| </s:states> |
| |
| <s:VGroup> |
| <s:List id="theList" useVirtualLayout="true" height="200"> |
| |
| <s:dataProvider> |
| <mx:AsyncListView id="theView" |
| createPendingItemFunction="pendingFunction" |
| createFailedItemFunction="errorFunction" |
| createPendingItemFunction.state3="pendingFunction7" |
| createFailedItemFunction.state3="errorFunction7"> |
| <mx:list> |
| <assets:ItemPendingErrorSimulator id="items1" |
| responseDelay="1" |
| numItems="20" |
| numPreloadedPages="0" |
| pageSize="1" |
| mode="'manual'" |
| objectFactory="theObjectFactory" |
| failureProbability="0" /> |
| </mx:list> |
| <mx:list.state4> |
| <assets:ItemPendingErrorSimulator id="items2" |
| responseDelay="1" |
| numItems="25" |
| numPreloadedPages="0" |
| pageSize="1" |
| mode="'manual'" |
| objectFactory="theObjectFactory" |
| failureProbability="0" /> |
| </mx:list.state4> |
| </mx:AsyncListView> |
| </s:dataProvider> |
| |
| <s:dataProvider.state2> |
| <mx:ArrayList> |
| <mx:source> |
| <fx:Array> |
| <fx:Object info="state2 item" status="present" /> |
| </fx:Array> |
| </mx:source> |
| </mx:ArrayList> |
| </s:dataProvider.state2> |
| |
| |
| <s:itemRenderer> |
| <fx:Component> |
| <s:ItemRenderer> |
| <fx:Script> |
| <![CDATA[ |
| private function getColor(obj:Object):uint{ |
| if(obj == null) |
| return 0x888888; |
| else if(obj.status == "pending") |
| return 0xeeffee; |
| else if(obj.status == "failed") |
| return 0xffeeee; |
| else |
| return 0xffffff; |
| } |
| |
| override public function set data(obj:Object):void{ |
| super.data = obj; |
| |
| if(data == null) |
| nameLabel.text = "null"; |
| else |
| nameLabel.text = data.info; |
| } |
| ]]> |
| </fx:Script> |
| <s:states> |
| <s:State name="normal" /> |
| <s:State name="hovered" /> |
| <s:State name="selected" /> |
| </s:states> |
| <s:Rect left="0" right="0" top="0" bottom="0"> |
| <s:fill> |
| <s:SolidColor color="{getColor(data)}" /> |
| </s:fill> |
| </s:Rect> |
| <!--s:Label id="nameLabel" text="{data.info}" top="5" left="5" right="5" /--> |
| <s:Label id="nameLabel" top="5" left="5" right="5" /> |
| </s:ItemRenderer> |
| </fx:Component> |
| </s:itemRenderer> |
| </s:List> |
| </s:VGroup> |
| </s:Group> |