This should hopefully populate a List Component with the appropriate data. The only issue comes from the fact that the XML mydata information is numeric ranging from 0 through 10313.
No matter how i sort the dataTag array it never puts the information into the respective order. The 10XXX figures always come ahead of the preceeding numerals.
Anyone come across this before who can point me in the right direction?
Mike
Last edited by michaeltowse; 08-20-2010 at 07:49 AM.
that works as much as the results show backwards but the results still don't show as I would expect them to. The 10XXX now show at the bottom but not in the order i had hoped....
Thanks for looking at the code gparis, i've loaded my current FLA and XML to the attached zip in case it helps shed a little light to the confusion i seem to be having....
I'm writing this just to subscribe so I can see the outcome. Michael, I downloaded your zip and the the application is doing what it seems it's supposed to other than It's not pulling some of the data from the other nodes when you select the dropdown. But, that looks like it's because it's looking for xml files not in the zip. So, I'm completely baffled as to what sort order you're looking for as gparis has hinted at: 10298 is coming after 9913 so maybe you are wanting something else?
in the fla You had:
dataTag.sortOn("data",Array.NUMERIC);
dataTag.sort(Array.DESCENDING);
you can do:
dataTag.sortOn("data", Array.NUMERIC | Array.DESCENDING);
Hi mneil, thanks for taking the file down for a look. I've attached another XML and FLA just incase I took a little too much from the original one.
At times the 10*** items do come after the others, but the list should run from smallest number to biggest number. When the 10*** are last in the list, the 9*** are first when it should be the 6*** first followed by 7 etc etc
I've tried variations hence the commented out code and extra node data.
I really want the data to run in a sequential order from lowest number to highest when the blue button is clicked.
I'm confident that I am just missing a step, or a few marbles.....
We all have a few marbles loose! So I looked and looked at this thing trying to figure it out. I rewrote it a bit and still nothing. I stared at the results, and stared. And thought, why is it sorting it like it's a string still. It's on NUMERIC? Duh, because it is a string, regardless. Convert your data to a Number. I have cs5 and can't save that far back but here's what I wrote:
PHP Code:
completeList = new XML(); completeList.ignoreWhite = true; completeList.onLoad = function(success) { if (success) { tcRecordings.removeAll(); mainheadings = this.firstChild.childNodes;
var dataTag:Array = []; for (var a = 0; a<mainheadings.length; a++) { newSub = this.firstChild.childNodes[a].childNodes; for (var i = 0; i<newSub.length; i++) { dataTag.push({ label:newSub[i].attributes.mydata ,data:Number(newSub[i].attributes.mydata) }); }