| <?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:Application height="800" width="800" |
| 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:comps="comps.*" |
| backgroundColor="0xFFFFFF" > |
| <s:layout> <s:VerticalLayout/> </s:layout> |
| <fx:Style source="assets/myStyles.css" /> |
| <fx:Script> |
| <![CDATA[ |
| import comps.*; |
| |
| import mx.collections.ArrayCollection; |
| import mx.core.IFlexDisplayObject; |
| import mx.events.CollectionEvent; |
| import mx.events.CollectionEventKind; |
| import mx.graphics.*; |
| import mx.managers.PopUpManager; |
| |
| import spark.collections.*; |
| import spark.components.*; |
| import spark.primitives.*; |
| import spark.primitives.supportClasses.*; |
| import spark.skins.spark.*; |
| |
| public var mylistPopUp:IFlexDisplayObject; |
| |
| [Bindable] |
| public var labelArr:Array=[{label: "top"},{label: "file"},{label:"I am a Menu"},{label:"here goes Nothing"},{label:"Label4"},{label:"bottom"}]; |
| [Bindable] |
| public var abcArr:Array=[' ','', 'A','B','C','D','E','F','G','H','I','J','K','L']; |
| [Bindable] |
| public var emptyArr:Array=[]; |
| public var mixArr:Array= [{type: "color", label: "Green string", color: 0x00FF00},{type: "text", label: "This is a string"},{type:"checkBox", label: "Checked", value:true}, |
| {type:"checkBox", label: "Unchecked", value:false},{type: "text", label: "Second string"}, |
| {type: "color", label: "Red string", color: 0xFF0000}]; |
| |
| [Bindable] |
| public var ac:ArrayCollection; |
| public var newPlayer:Object = {team:"ATeam",jerseyNumber:15, lastName:"Smith", firstName:"Sam"}; |
| [Bindable] |
| public var players:ArrayCollection; |
| [Bindable] |
| public var ellipseAC:ArrayCollection; |
| public function createPlayersAC():ArrayCollection |
| { |
| players = new ArrayCollection([ |
| {team:"ATeam",jerseyNumber:80, lastName:"BrPlayer", firstName:"TrName"}, |
| {team:"BTeam", jerseyNumber:7, lastName:"LePlayer", firstName:"ByName"}, |
| {team:"ATeam",jerseyNumber:12, lastName:"BryPlayer", firstName:"ToName"}, |
| {team:"ATeam",jerseyNumber:21, lastName:"GaPlayer", firstName:"RaPlayer"}, |
| {team:"CTeam", jerseyNumber:34, lastName:"OrPlayer", firstName:"DaName"}, |
| {team:"ATeam",jerseyNumber:12, lastName:"ViPlayer",firstName:"AdName"}, |
| {team:"BTeam", jerseyNumber:7, lastName:"Boon", firstName:"ByName"}, |
| ]); |
| return players; |
| } |
| public function createEllipseAC():void |
| { |
| ellipseAC = new ArrayCollection([ |
| {label:"red",width:80, height:10, color:"0xFF0000"}, |
| {label:"green",width:50, height:20, color:"0x00FF00"}, |
| {label:"gray",width:30, height:60, color:"0x999999"}, |
| {label:"red circle",width:50, height:50, color:"0xFF0000"}, |
| {label:"yellow",width:40, height:10, color:"0xFFFF00"}, |
| {label:"magenta",width:70, height:30, color:"0xFF00FF"}, |
| {label:"aqua",width:30, height:40, color:"0x00FFFF"} |
| ]); |
| } |
| public function sortAC():ArrayCollection |
| { |
| ac = new ArrayCollection([ |
| {team:"ATeam",jerseyNumber:80, lastName:"BrPlayer", firstName:"TrName"}, |
| {team:"BTeam", jerseyNumber:7, lastName:"LePlayer", firstName:"ByName"}, |
| {team:"ATeam",jerseyNumber:12, lastName:"BryPlayer", firstName:"ToName"}, |
| {team:"ATeam",jerseyNumber:21, lastName:"GaPlayer", firstName:"RaPlayer"}, |
| {team:"CTeam", jerseyNumber:34, lastName:"OrPlayer", firstName:"DaName"}, |
| {team:"ATeam",jerseyNumber:12, lastName:"ViPlayer",firstName:"AdName"}, |
| {team:"BTeam", jerseyNumber:7, lastName:"Boon", firstName:"ByName"}, |
| ]); |
| var s:spark.collections.Sort = new spark.collections.Sort(); |
| var f:spark.collections.SortField = new spark.collections.SortField("jerseyNumber"); |
| this.addStyleClient(s); |
| this.addStyleClient(f); |
| ac.filterFunction = function (item:Object):Boolean |
| { |
| return item.jerseyNumber >= 12 && item.jerseyNumber <= 34; |
| } |
| s.fields = [f]; |
| ac.sort = s; |
| ac.refresh(); |
| return ac; |
| } |
| public function myItemRendererFunction(item:*):IFactory |
| { |
| if(item.type == "text") |
| return (new ClassFactory(LabelRenderer)); |
| else if (item.type == "checkBox" ) |
| return (new ClassFactory(CheckBoxRenderer)) |
| else if (item.type == "color" ) |
| return (new ClassFactory(ColorLabelRenderer)) |
| return (item); |
| } |
| public function aligningItemRendererFunction(item:*):IFactory |
| { |
| if (item is DisplayObject || item is GraphicElement) |
| return new ClassFactory(DataGroupJustifyItemRendererComplex); |
| else |
| return new ClassFactory(DataGroupJustifyItemRenderer); |
| } |
| |
| public function createAC():ArrayCollection |
| { |
| var col:ArrayCollection = |
| new ArrayCollection(['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']); |
| return (col); |
| } |
| public function createNullDupAC():ArrayCollection |
| { |
| var col:ArrayCollection = |
| new ArrayCollection([null,'A',null,'A','a','a','a','B','C','D','E','F','G','H','I','J','K', |
| 'L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','a','aa','aa',null,null]); |
| return (col); |
| } |
| public function addEllipseAt(myList:List, i:int, color:int, width:int=40, height:int=30):void |
| { |
| var myGroup:Group = new Group(); |
| var myEllipse:Ellipse = new Ellipse(); |
| myEllipse.width=width; myEllipse.height=height; |
| var myFill:SolidColor = new SolidColor(); |
| myFill.color = color; |
| myEllipse.fill = myFill; |
| myGroup.addElement(myEllipse); |
| myList.dataProvider.addItemAt(myGroup, i); |
| } |
| public function addRectAt(myList:List, i:int, color:int, width:int=15, height:int=30, x:int=30, y:int=40):void |
| { |
| var myGroup:Group = new Group(); |
| var myRect:Rect = new Rect(); |
| myRect.x = x; myRect.y = y; |
| myRect.width=width; myRect.height=height; |
| var myFill:SolidColor = new SolidColor(); |
| myFill.color = color; |
| myRect.fill = myFill; |
| myGroup.addElement(myRect); |
| myList.dataProvider.addItemAt(myGroup,i); |
| } |
| public function createLine(color:int, xFrom:int=0, yFrom:int=0,xTo:int=40, yTo:int=30 ):Line |
| { |
| var myLine:Line = new Line(); |
| myLine.xFrom = xFrom; myLine.yFrom = yFrom; |
| myLine.xTo=xTo; myLine.yTo=yTo; |
| var mySolidColorStroke:SolidColorStroke = new SolidColorStroke(); |
| mySolidColorStroke.color = color; |
| myLine.stroke = mySolidColorStroke; |
| return myLine; |
| } |
| public function createGroup(color:int, width:int=40, height:int=40, x:int=0, y:int=0 ):Group |
| { |
| var myGroup:Group = new Group(); |
| myGroup.layout = new VerticalLayout(); |
| |
| var myEllipse:Ellipse = new Ellipse(); |
| myEllipse.width=width; myEllipse.height=height; |
| var myFill:SolidColor = new SolidColor(); |
| myFill.color = color; |
| myEllipse.fill = myFill; |
| myGroup.addElement(myEllipse); |
| |
| var myRect:Rect = new Rect(); |
| myRect.width=width; myRect.height=height; |
| myRect.fill = myFill; |
| myGroup.addElement(myRect); |
| |
| myGroup.addElement(createLine(color)); |
| |
| return myGroup; |
| } |
| |
| public function mixItemRendererFunction(item:*):IFactory |
| { |
| if (item is DisplayObject || item is GraphicElement) |
| return new ClassFactory(DefaultComplexItemRenderer); |
| else |
| return new ClassFactory(DefaultItemRenderer); |
| } |
| |
| public function useDefaultComplexItemRenderer(item:*):IFactory |
| { |
| return new ClassFactory(DefaultComplexItemRenderer); |
| } |
| |
| public function teamLabelFunction(item:Object):String |
| { |
| if (item.team=="ATeam") |
| return("TeamA " + item.lastName + item.firstName) |
| else |
| return("Other Team" + item.lastName + item.firstName) |
| } |
| public function jerseyNumberLabelFunction(item:Object):String |
| { |
| return( item.lastName + item.firstName + item.jerseyNumber ) |
| } |
| public function openPopUp(modalSetting:Boolean): void |
| { |
| mylistPopUp = PopUpManager.createPopUp(this, comps.ListPopUp, modalSetting); |
| } |
| |
| public function closePopUp(): void |
| { |
| PopUpManager.removePopUp(mylistPopUp); |
| } |
| public var collectionChangeResults:String; |
| |
| public function resetCollectionChangeResults():String |
| { |
| collectionChangeResults = ""; |
| return "complete"; |
| } |
| |
| public function handleCollectionChangeResults(e:CollectionEvent):void |
| { |
| collectionChangeResults += e.kind + ""; |
| } |
| |
| public function kickoffCollectionChangeMoveEvent(list1:List):int { |
| var sort:Sort = new Sort(); |
| var sortField:SortField = new SortField("value",false); |
| this.addStyleClient(sort); |
| this.addStyleClient(sortField); |
| // var sort:mx.collections.Sort = new mx.collections.Sort(); |
| // var sortField:mx.collections.SortField = new mx.collections.SortField("value",true); |
| sort.fields = [sortField]; |
| ArrayCollection(list1.dataProvider).sort = sort; |
| ArrayCollection(list1.dataProvider).refresh(); |
| list1.validateNow(); |
| list1.validateDisplayList(); |
| |
| var to:Object = list1.dataProvider.getItemAt(0); |
| lb.text = to.value; |
| |
| to.value = "yello1"; |
| list1.dataProvider.itemUpdated(list1.dataProvider.getItemAt(0)); |
| return 1; |
| } |
| ]]> |
| </fx:Script> |
| |
| <s:List id="list1" dataProvider="{new ArrayCollection([])}" /> |
| <s:List id="list2" dataProvider="{new ArrayCollection([])}" itemRendererFunction="mixItemRendererFunction"/> |
| <comps:ItemRendRETComp id="list3" /> |
| <comps:ItemRendRETLabelComp id="list4" /> |
| <comps:ItemRendRETComp1 id="list5" /> |
| |
| <s:Label id="lb" /> |
| </s:Application> |