<?xml version="1.0" encoding="utf-8"?>
<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"
minWidth="955" minHeight="600" pageTitle="滤镜函数示例">
<!--fileName: TheUseOfFilterFunction-->
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.SliderEvent;
[Bindable]
public var salesAC:ArrayCollection = new ArrayCollection([
{name: "加拿大", sales: 295323},
{name: "美国", sales: 982832},
{name: "英格兰", sales: 109283},
{name: "巴西", sales: 12495},
{name: "印度", sales: 597232},
{name: "中国", sales: 682011}
]);
public function filterFun(item:Object):Boolean
{
if(item.sales >= salesRange.values[0] && item.sales <= salesRange.values[1]) {
return true;
}else {
return false;
}
}
protected function salesRange_changeHandler(event:SliderEvent):void
{
salesAC.filterFunction = filterFun;
salesAC.refresh();
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<!--view-->
<mx:Panel width="400" height="300" title="销售量统计" verticalCenter="0" horizontalCenter="0">
<mx:HSlider id="salesRange" change="salesRange_changeHandler(event)" width="100%"
thumbCount="2" labels="['0', '250000', '500000', '750000', '1000000']"
tickInterval="50000" height="50" maximum="1000000"/>
<mx:DataGrid id="dgrid" dataProvider="{salesAC}" width="100%" height="100%">
<mx:columns>
<mx:DataGridColumn headerText="国家" dataField="name"/>
<mx:DataGridColumn headerText="销售量" dataField="sales"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
</s:Application>
<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"
minWidth="955" minHeight="600" pageTitle="滤镜函数示例">
<!--fileName: TheUseOfFilterFunction-->
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.SliderEvent;
[Bindable]
public var salesAC:ArrayCollection = new ArrayCollection([
{name: "加拿大", sales: 295323},
{name: "美国", sales: 982832},
{name: "英格兰", sales: 109283},
{name: "巴西", sales: 12495},
{name: "印度", sales: 597232},
{name: "中国", sales: 682011}
]);
public function filterFun(item:Object):Boolean
{
if(item.sales >= salesRange.values[0] && item.sales <= salesRange.values[1]) {
return true;
}else {
return false;
}
}
protected function salesRange_changeHandler(event:SliderEvent):void
{
salesAC.filterFunction = filterFun;
salesAC.refresh();
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<!--view-->
<mx:Panel width="400" height="300" title="销售量统计" verticalCenter="0" horizontalCenter="0">
<mx:HSlider id="salesRange" change="salesRange_changeHandler(event)" width="100%"
thumbCount="2" labels="['0', '250000', '500000', '750000', '1000000']"
tickInterval="50000" height="50" maximum="1000000"/>
<mx:DataGrid id="dgrid" dataProvider="{salesAC}" width="100%" height="100%">
<mx:columns>
<mx:DataGridColumn headerText="国家" dataField="name"/>
<mx:DataGridColumn headerText="销售量" dataField="sales"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
</s:Application>