ActionScript 2.0 :: Sorting An XML?
Nov 26, 2003Given an XML file similar to this:
Code:
<class>
<student>
[code].....
Given an XML file similar to this:
Code:
<class>
<student>
[code].....
I have been deveolping my new site, which is in it's early stages and have most things working ok but i need to open new windows from buttons in the main swf file. please check out my link to see for yourself! new windows load in the same window ad the main swf. [URL] I have been using this code on the thumbs on my design and illustration sections
on (release) {
getURL("javascript:NewWindow=window.open('url.html ','newWin','width=1133,height=425,left=425,top=113 3,screenX=1133,screenY=425');NewWindow.focus();voi d(0);");
}
each of the thumb windows being a different specified size.
Is there any way in Flex where in we can sort an arraycollection based on strings .I have a dataprovider with strings like "Critical" "High" "Medium" "Low" where in I need to sort it in such a way that I need Critical to be displayed on the top and next High , Medium and Low follows.
View 1 RepliesI have an advancedDataGrid and I would like to sort the adg according one AdvancedDataGridColumn(studyDate) which use strings in format DD/MM /YYYY(I receive like this from the server):But i find another problem, I need to sort the columns of the adg the first time it displays so I used the following function but It doesn't sort from the recent day to old one, I do not know what I can I do cause I set sort.descending= true, any ideas?[code]
View 1 RepliesI have a one comboBox that I fill as:
for (var key:String in values) {
conns.addItem(key);
}
After that I sorted my ComboBox as:
private function sortConnection():void {
var dataSortField:SortField = new SortField();
dataSortField.name = "data";
dataSortField.numeric = true;
var numericDataSort:Sort = new Sort();
numericDataSort.fields = [dataSortField];
conns.sort = numericDataSort;
conns.refresh();
}
And on finish I want to select item on my specific value in ComboBox. How can I do that? I try:
for (var ii:Number=0; ii<combo.rowCount; ii++) {
var item:String = combo.getChildAt(ii);
if (item == name) {
index = ii;
}}
But does not work. I do not know where I made mistake, and how I can select on specific item in my combobox.
I have been trying to sort an XMLListCollection following instructions like this for some time, without success. Here's the relevant code:
<fx:Declarations>
<s:HTTPService id="photoServ" url="pics.xml" resultFormat="e4x"/>
<s:XMLListCollection id="photoList" source = "{photoServ.lastResult.photo}"/>
[code]......
i'm trying to sort out some xml entries based on an attribute when you click a button. an example of my xml is below.
Code:
<list>
<entries cat="all">
[code].....
i just started with isometrics. i got the 3d to 2d coordinates working but i cant seem to get the z sorting to work.
View 2 Repliesi just started with isometrics. i got the 3d to 2d coordinates working but i cant seem to get the z sorting to work. please check the fla if you have knowledge in the subject.
View 6 RepliesTrying to re-sort an array of objects from:
var arr:Array = new Array({num:0},{num:1},{num:2},{num:3})
to
var arr:Array = ({num:0},{num:3},{num:1},{num:2})
- Put a bunch of MC's on the stage distributed horizontally.
- Store them in an array.
- yourArray.sortOn("x", Array.DESCENDING)
- loop though the now "sorted" array and trace their x property.
Doesn't work, does it? If it did, shuffle them up and try again (sometimes, perhaps randomly they will be in order).
I'm trying to bring XML nodes into an array so I can sort them in alphabetical order, then display the data in some textfields in a movieclip.I've managed to get the XML displaying fine in the movieclips and all the data in the arrays, but the problem is I'm not sure where to use name.sort();. Right now you can see I have it at the start of the loop that places all the data in, but it will only sort as it populates and hence becomes pointless.Is there a way to add all the data into an array, sort it, THEN display all the data in my movieClips?My XML looks like this:
PHP Code:
<example><item><name>Zack</name><donation>99</donation><message>Zacks msg</message></item><item><name>John</name><donation>70</donation><message>Johns msg</message></item><item><
[code]......
Rows B, D and E do not sort correctly, basically because I am assuming they have numbers with unmatching or too many places. I can not find any help online with this. The columns with percentages work fine unless they go over 99%. ?[code]...
View 7 RepliesI have this array
Code:
_global.itemsSelected[1][0]=20;
_global.itemsSelected[1][1]=60;
_global.itemsSelected[1][2]=10;
[Code]....
In the project I'm working on, there are towers the user can place. However, it you place a tower higher then another one, it appears infront of that one, which looks weird.I want to be able to arrange all the towers so that that does not happen.There is an sprite called towerHolder holding, which all the towers are children of, and an array called towerArray, which the towers get pushed to when they are created.I tried clearing towerHolder, then running the sortOn() function on the array, and then adding each tower back to the towerHolder, but the towers just seem to be randomly placing themselves irrelevent to their height.Here's my code for the relevant parts:
Actionscript Code:
function clearTowers():void { while (towerHolder.numChildren > 0) { towerHolder.removeChildAt(0); }}function orderTowers():void { clearTowers();
[code]....
have a twodimensional array that consists of 6 other arrays(like array[0 to 5][0 to 4]). The [4] of each sub-array is a indexnumber that i'd like to use for sorting the array[0][x] toarray[5][x] according to their array[x][4]-value. How would I do
View 3 Replieswould anyone beable to help with sorting out an XML file, what I have is a tooltip that loads in via XML and exported from flash. the XML loads in 2 text fields, field and field2. what I am trying to do is add a button also to the tooltip so that you can click and go to a url. this is what I have in my XML file;
[Code]...
How would I do to sort this array by the largest sum and not just the first number?
var myArray:Array = new Array(100, 200, 9);
myArray.sort(Array.DESCENDING)
//puts out (9, 200, 100)
How would I do to get it (200, 100, 9)?
I have a datagrid that uses a custom cellrenderer class to allow me to use a combobox. I have an invisible column that holds the value returned by the cellrenderer when the combobox value is changed. BUT sorting is wonky. Since what really lives in the combobox column individual cells is an object, it never really sorts properly. Is there a way to fire a sorting event to the column that holds the real value?
View 4 RepliesI have a vector of Objects. Each object has two properties - a country and a person's name.
I'd like to sort & count the number of people from whatever country they are from...
i.e.
20 USA
18 France
16 England
I've found articles online that deal with sorting, but I'd like to be able to count the objects' "country" properties dynamically because they aren't known beforehand (I don't want to loop through every country).
With flash builder and away3d I have made a 3D building where you can walk through.
When you start, you are outside the building and you can enter the building through a door. This building has an outside wall made of bricks and an inside wall. There is a little space between the inside wall and the outside wall (just as a cavity wall).
But when I walk outside the building, I can see sometimes parts of the inside wall through the outside wall (depth sorting problem). The same as I walk into the building, I see parts of the outside wall through the inside wall. Some of these depth sorting problems you can solve with pushfront and pushback, but not all. For example when you are outside the building, you can use pushfront for the outside wall.
You don't see the inside wall through the outside wall anymore. But when you walk into the building you see the outside wall through the inside wall (of course because you used pushfront for the outside wall). Actually it depends on your position in the 3D space for which wall you have to use pushback or pushfront. Is there a way to solve this kind of depth sorting problems?
I have a column with 4 fields named : a> Main, b> Forward c> Back d> Link, if I use pre-defined sorting of datagrid with the column names which will be alphabetically, then the order is c>Back b>Forward d> Link a> Main. But, I do not want to sort based on the alphabets. I prefer to sort by names of the column fields. i.e. somehow give priority to each individual column field names. Like pre-define my own order.
View 2 RepliesIn a Flex webapp, is there an easy way to go about applying a sort to the children of an XML element, based on the children's attributes? Example follows below:
XMLListCollection:
<a anotherProp="ABCDE">
<e prop="AB">1</element>
<e prop="BC">2</element>
</a><a anotherProp="FGEH">
<e prop="HF">3</element>
<e prop="AD">4</element>
<e prop="AC">5</element></a>
I would like to sort the <e> elements, within each <a> element separately, according to their "prop" attribute. My code for generating the array containing the <a> elements is along the lines of:
for each(var node:XML in initialInput:XMLListCollection){
if(node.localName()=="a"){
//I was hoping to be able to sort the <e> children of the node variable here
xmlListCollectionVar.addItem(node);
}}
At the end I would like the <a>'s to remain in their defined order, but their <e> children to be sorted based on the "prop" attribute. So far if I try:
node.children().sort=someSortVar
Where someSortVar has its fields set to:
SortFields("e.@prop",...)
I get an exception about a null value. Any way to convert the children list to XMLListCollection, sort it and integrate it back into the node variable?
I have a datagrid with data like this:
[Code]...
I have a Advanced Datagrid with sorting. I think it is string sorting by default. But i need the sorting in number. How can i achieve the number sorting.for example: i have row numbers like 1 to 100 . i need number sorting like 1,10,100.
View 2 RepliesI'm trying to sort an array of objects with ActionScript 3.
The array is like this:
var arr:Array = new Array ();
arr.push ({name:"John", date:"20080324", message:"Hi"});
arr.push ({name:"Susan", date:"20090528", message:"hello"});
can I do something with Array.sort(...) method?
How can i accomplish sorting an array according to two values. Is there built in function for that?
View 2 RepliesI am loading data from an xml file into several different arrays. Once its all information is in the arrays I then sort one of the arrays (called percentage) numerically from highest to lowest. What I can't figure out is how to reflect the changes in position in the other arrays to what has happened in the percentage array.
View 6 RepliesI am trying to sort an array that is generated thru an xml file.
The XML has "sections" that are used to generate a different view type, it is NOT used here but is needed for other features. What IS used is the artist name & ID. This function takes the data from XML and takes the name and ID from each section and puts it into 2 separate Arrays, "nameArr" and "noArr". After these two new arrays are created they are sent into an object "sectionData". The objects are then sent into a new Array "multiArr". This looks a little overkill but it is needed to create a new array without the section info.
I am trying to sort this new array multiArr using the "sortOn" method by "ID" to sort it by id but it is not working. It doesn't sort the array.
ActionScript Code:
public function setListData( data:Array ) {
var sectionData:Object = {};
[Code]......
Iam trying to do a highscore list which is generated on a website as Xml and then send to Flash. I have got the Xml to be loaded into Flash but the probelm is that i want them to be sorted in so the highest score is on the top and then its going to down to the lowest score.
[Code].....