blob: 0f2a432ae309e05344c71f5a74fdaefbb5a849bb [file]
<?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">
<!--
This is different in that it uses data binding to populate the label of the
itemRenderer. We don't do that in the rest of the tests because it causes
warnings.
-->
<fx:Script>
<![CDATA[
import flash.events.Event;
import mx.collections.*;
import mx.collections.errors.*;
import mx.events.CollectionEvent;
// Public so we can access it, e.g., to be sure it dispatches events.
public var alv:AsyncListView;
// The ever famous simulator.
public var items:ItemPendingErrorSimulator;
// Added items start at 5000 so we can tell which ones those are.
public var addedItems:int = 5000;
/**
* This allows you to set a bunch of parameters.
**/
public function setup( responseDelay:int = 500,
numItems:int = 100,
numPreloadedPages:int = 0,
pageSize:int = 1,
mode:String = 'manual',
failureProbability:int = 0,
createPendingItemFunction:Boolean = true,
createFailedItemFunction:Boolean = true):void{
items = new ItemPendingErrorSimulator();
items.responseDelay = responseDelay;
items.numItems = numItems;
items.numPreloadedPages = numPreloadedPages;
items.pageSize = pageSize;
items.mode = mode;
items.failureProbability = failureProbability;
items.objectFactory = theObjectFactory;
items.reset();
alv = new AsyncListView(items);
if(createPendingItemFunction)
alv.createPendingItemFunction = pendingFunction;
if(createFailedItemFunction)
alv.createFailedItemFunction = errorFunction;
theList.dataProvider = alv;
}
public function pendingFunction(i:int, obj:Object):Object{
return {info: "item " + i.toString() + " pending", status: "pending"};
}
public function errorFunction(i:int, obj:Object):Object{
return {info: "item " + i.toString() + " failed", status: "failed"};
}
public function theObjectFactory(i:int):Object{
return {info: "item " + i.toString() + " present", status: "present"};
}
]]>
</fx:Script>
<s:List id="theList" useVirtualLayout="true" height="200">
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<s:states>
<s:State name="normal" />
<s:State name="hovered" />
<s:State name="selected" />
</s:states>
<s:Label id="nameLabel" top="5" left="5" right="5" text="{data.info}" />
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
</s:Group>