| <?xml version="1.0" encoding="iso-8859-1"?> |
| <!-- |
| |
| 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. |
| |
| --> |
| <mx:Application backgroundColor="0xFFFFFF" |
| xmlns:mx="http://www.adobe.com/2006/mxml" |
| xmlns:s="library://ns.adobe.com/flex/spark"> |
| |
| <mx:Script> |
| <![CDATA[ |
| |
| import mx.collections.ArrayCollection; |
| import mx.collections.ListCollectionView; |
| import mx.collections.IViewCursor; |
| import mx.collections.XMLListCollection; |
| import spark.collections.*; |
| |
| public function filterFunc(item:Object):Boolean |
| { |
| return item.name >= "Houston" && item.name <= "New York"; |
| } |
| |
| public var xmlData:XML = |
| <root> |
| <!-- I am a comment above employee --> |
| <employee id="1111-111-1111"> |
| <!-- I am a nested comment --> |
| <first-name>Bob</first-name> |
| <last-name>Freely</last-name> |
| <age>25</age> |
| <address> |
| <street>111 Main</street> |
| </address> |
| </employee> |
| <employee id="2222-222-2222"> |
| <first-name>Anders</first-name> |
| <last-name>Wiley</last-name> |
| <age>26</age> |
| <address> |
| <street>222 Main</street> |
| </address> |
| </employee> |
| <employee id="3333-333-3333"> |
| <first-name>Cathy</first-name> |
| <last-name>Wayens</last-name> |
| <age>22</age> |
| <address> |
| <street>333 Main</street> |
| </address> |
| </employee> |
| <employee id="3333-333-3333"> |
| <first-name>Smith</first-name> |
| <last-name>Nearly</last-name> |
| <age>32</age> |
| <address> |
| <street>444 Main</street> |
| </address> |
| </employee> |
| </root>; |
| public var colXML_AS:XMLListCollection;; |
| public var colArr_AS:ArrayCollection; |
| public var cursorXML_AS:IViewCursor; |
| public var cursorArr_AS:IViewCursor; |
| public var cursorArr_Airport:IViewCursor; |
| public var cursorArr_Inline:IViewCursor ; |
| |
| public function initEmployees():void |
| { |
| //apply the appropriate Sorts |
| var sortXML:spark.collections.Sort = new spark.collections.Sort(); |
| var sortFieldXML:spark.collections.SortField = new spark.collections.SortField("last-name"); |
| this.addStyleClient(sortXML); |
| this.addStyleClient(sortFieldXML); |
| sortXML.fields=[sortFieldXML]; |
| colXML_AS = new XMLListCollection(xmlData.employee) |
| colXML_AS.sort=sortXML; |
| colXML_AS.refresh(); |
| cursorXML_AS = colXML_AS.createCursor(); |
| } |
| ]]> |
| </mx:Script> |
| |
| <mx:ArrayCollection id="airportCollectionSorted" filterFunction="filterFunc"> |
| <mx:source> |
| <mx:Array> |
| <mx:Object abbreviation="IAH" name="Houston" international="true"/> |
| <mx:Object abbreviation="BOS" name="Boston" international="true"/> |
| <mx:Object abbreviation="MHT" name="Manchester" international="false"/> |
| <mx:Object abbreviation="JAX" name="Jacksonville" international="false"/> |
| <mx:Object abbreviation="CVG" name="Cincinatti" international="false"/> |
| <mx:Object abbreviation="ATL" name="Atlanta" international="true"/> |
| <mx:Object abbreviation="CDG" name="Paris" international="true"/> |
| <mx:Object abbreviation="JFK" name="New York" international="true"/> |
| <mx:Object abbreviation="LAX" name="Los Angeles" international="true"/> |
| <mx:Object abbreviation="HND" name="Tokyo" international="true"/> |
| </mx:Array> |
| </mx:source> |
| <mx:sort> |
| <s:Sort> |
| <s:fields> |
| <mx:Array> |
| <s:SortField name="name" locale="en-US"/> |
| </mx:Array> |
| </s:fields> |
| </s:Sort> |
| </mx:sort> |
| </mx:ArrayCollection> |
| |
| |
| </mx:Application> |