ArrayCollection get maximum value and get minimum value
<?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=" the"> <fx:Declarations> <!--Place non-visual elements (such as services, value objects) here--</Fx:declarations> <fx:Script> <![cdata[Importmx.collections.ArrayCollection; ImportMx.collections.Sort; ImportMx.collections.SortField; ImportMx.controls.Alert; [Bindable] Public varColl:arraycollection =Newarraycollection ([{getinfotime:' 2013-04-23 10:00am ', Waterheight:6}, {getinfotime:' 2013-04-23 10:02 ', Waterheight:2}, {getinfotime:' 2013-04-23 10:04 ', Waterheight:3}, {getinfotime:' 2013-04-23 10:06 ', waterheight:1000}, {getinfotime:' 2013-04-23 10:08 ', waterheight:5.0}, {getinfotime:' 2013-04-23 10:10 ', waterheight:2000} ]); //Get A function of the maximum Public functionBtn_getmaxvalue_clickhandler ():void{ varSort:sort =NewSort (); //Sort by Waterheight ascendingsort.fields=[NewSortField ("Waterheight")]; Coll.sort=sort; Coll.refresh (); Alert.show (Coll[coll.length-1].waterheight); } //Get A function of the minimum Public functionBtn_getminvalue_clickhandler ():void{ varSort:sort =NewSort (); //Sort by Waterheight ascendingsort.fields=[NewSortField ("Waterheight")]; Coll.sort=sort; Coll.refresh (); Alert.show (coll[0].waterheight); } ]]> </Fx:script> <s:button x="171"y="156"Width=" the"height="to"Label="Get maximum Value"click="Btn_getmaxvalue_clickhandler ();" /> <s:button x="321"y="157"Width=" the"height="to"Label="Get minimum Value"click="Btn_getminvalue_clickhandler ();" /> </S:application>
ArrayCollection get maximum value and get minimum value