|
I tried what you said and what I thought was the Array.sort command but I can not get it to work. What I am trying to do in a nutshell is sort the array by showing the top three numbers in order on either a button or a label next to there respective Shoppers. I looked online for info on the Array.sort() function but I could not see a good example of it in use?
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"> <mx:Array id="apples"> <mx:Object> <label>Shopper1</label> <Number>5</Number> </mx:Object> <mx:Object> <label>Shopper2</label> <Number>7</Number> </mx:Object> <mx:Object> <label>Shopper3</label> <Number>0</Number> </mx:Object> <mx:Object> <label>Shopper4</label> <Number>4</Number> </mx:Object> <mx:Object> <label>Shopper5</label> <Number>1</Number> </mx:Object> <mx:Object> <label>Shopper6</label> <Number>0</Number> </mx:Object> <mx:Object>
<label>Shopper7</label> <Number>0</Number> </mx:Object> <mx:Object> <label>Shopper8</label> <Number>0</Number> </mx:Object> </mx:Array> <mx:Script> <![CDATA[ public function getorder():Void { Array.apples.sort(label,Number) firstplaceshopper.label=apples[0].label mostapples.label=apples[0].Number secondplaceshopper.label=apples[1].label secondmostapples.label=apples[1].Number thirdplaceshopper.label=apples[2].label thirdmostapples.label=apples[2].Number } ]]> </mx:Script> <mx:HBox id="whohasthemost" visible="true"> <mx:Button label="firstshopper" /> <mx:Button width="100" id="firstplaceshopper" /> <mx:Button label="Number of apples" /> <mx:Button width="30" id="mostapples"/> <mx:Button label="secondshopper" />
<mx:Button width="100" id="secondplaceshopper" /> <mx:Button label="Number of apples" /> <mx:Button width="30" id="secondmostapples"/> <mx:Button label="thirdshopper" /> <mx:Button width="100" id="thirdplaceshopper" /> <mx:Button label="Number of apples" /> <mx:Button width="30" id="thirdmostapples"/> <mx:Button label="gettopthree" click="getorder()"/>
</mx:HBox>
</mx:Application> Yahoo! Groups Links
|
- Re: [flexcoders] Is there an easy way to do this nostra72
- Re: [flexcoders] Is there an easy way to do this Manish Jethani
- RE: [flexcoders] Is there an easy way to do this Tracy Spratt
- RE: [flexcoders] Is there an easy way to do this Tracy Spratt

