ActionScript 3.0 :: Flash - SortOn() Array Function?

Apr 13, 2011

I have an array of objects. The objects have a base class with various properties. Each time an object gets created, I push it into the array. However, I need to sort the objects based on one of their properties.Lets say in my object class, I have a function "ReturnNumber()" that returns a number, I want to sort my array based on which number was the highest. Can I use SortOn() to do this?

View 1 Replies


Similar Posts:


IDE :: Flash SortOn Function Not Working Properly?

Dec 6, 2009

Code:
var vendor_arr:Array = new Array();
//vendor_arr.push(new Array());
var level1:Array = new Array("yelp","yelp","yelp","yelp","yelp","yelp");
var level2:Array = new Array("a","b","c","d","e","f");
var level3:Array = new Array(12,14,7,2,11,24);
[Code] .....
Why is it not sorting on "bdistance" ?? its returning 2, 14, 7, 12, 11, 24... what kind of sorting is this??

View 1 Replies

ActionScript 2.0 :: SortOn(DECENDING) For The Number Array And Then Have The String Array Sort To Match

Jun 14, 2007

I have two arrays. One contains numbers and the other contains strings. I want to do a sortOn(DECENDING) for the number array and then have the string array sort to match. if my string array is

[Code]....

View 6 Replies

ActionScript 2.0 :: CS3 SortOn A NUMERIC Array

Aug 20, 2010

I have a button on the screen with the the following code attached to it's release function.

[Code]...

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?

View 10 Replies

ActionScript 2.0 :: Sorting An Array Using SortOn

Feb 17, 2009

I 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]......

View 5 Replies

ActionScript :: Array.sortOn() For Non-English Data?

Nov 13, 2010

this is an array of objects that i want to alphabetize:

var streets:Array = new Array();
streets.push({name:"Édouard-Montpetit"});
streets.push({name:"Alexandre de Sève"});
streets.push({name:"Van Horne"});
streets.push({name:"Atwater"});

now i'll sort my array:

streets.sortOn("name", Array.CASEINSENSITIVE);
//Sorted
Alexandre de Sève
Atwater
Van Horne
Édouard-Montpetit

the accent above the E in Édouard-Montpetit, and any other first letter with a non-english accent is sorted after Z.how i can sort this correctly? i do not have access to the named data.

View 1 Replies

ActionScript 2.0 :: Array: SortOn() Letters With Numbers?

Jan 5, 2009

I have an Array of objects that each have a Name and a Score. I can sort the Array with '.sortOn()' by the object's Name or the Score, but when I sort by the Score, if some Names have the same Score, they don't list Alphabetically within that Score.
The following code shows what I mean. The Names with a Score of 50 are together when listed by Score, but they are not Alphabetical. How do I combine both ways of sorting?

[Code]....

View 1 Replies

ActionScript 3.0 :: SortOn Alphanumeric Array Which Holds Objects?

Apr 7, 2010

I have an array which holds objects. The objects have properties called cat and title. The cat property can hold values like:
Cat 1
Cat 2
Cat 3

And the title property can hold values:
Title 1
Title 2
Title 3

So that you wind up with something that looks like
Cat 1
Title 1

Cat 1
Title 2

Cat 2
Title 3
etc.

Now, I want to sort these, but we all know that Array.sortOn(["cat", "title"]) will produce results like:
Cat 1
Cat 10
Cat 11
Cat 2
Cat 3

What's the most efficient method of sorting these properly (so the number component sorts like a number and not like a string)? I can request users pad their entries (yes, other people will be entering this data), but that's both a little bit ugly and not very user friendly.

View 2 Replies

ActionScript 2.0 :: Array.sortOn With String And Integer Flawed?

May 12, 2006

I'm using the sortOn method to sort my array. concider this array:

var list:Array = new Array();
list.push( {id: "1"} );
list.push( {id: "4"} );
list.push( {id: "12"} );

[code]....

How can this be fixed? I want my sort to have the following result:

fubar1, fubar4, fubar9, fubar12, fubar23

View 6 Replies

ActionScript 2.0 :: Multidimensinal Array SortOn() No Field Names?

Sep 23, 2006

My multidimensional array is created this way :

Code:
cards_array = new Array()
z=0

[code].....

View 3 Replies

ActionScript 2.0 :: Array.sortOn With Objects Of A Custom Class?

Jul 27, 2007

I'm trying to do Array.sortOn on an array of custom-class objects. It's not working, though nothing in the documentation suggests that this is a problem. Below is the code. I'm confident the MetricRecord constructor is working fine because everything else works, and the traces below are correct, except they don't sort.

// This array sorts
metricRecords = new Array();
metricRecords.push({mediaVehicle:"cca", temp:"asxcvbxcber"});
metricRecords.push({mediaVehicle:"aaa", temp:"asdfertr"});

[Code]....

View 1 Replies

ActionScript 3.0 :: Error #1006: SortOn Is Not A Function

Aug 30, 2009

While I was finishing the details of the carousel from my last thread another error occured which i cant remove :

ActionScript Code:
TypeError: Error #1006: sortOn is not a function.
at circle_of_buttons_fla::MainTimeline/enterFrameHandler()

The whole day almostly i was trying to figure it out but I couldn't so i will be grateful if someone can help

[Code]...

View 1 Replies

ActionScript 3.0 :: Flash SortOn Messing Up Arrays

Feb 24, 2011

I'm using the .sortOn() function in AS3.0 to sort an array with multiple elements.First, I push the values to the array, like this:[code] The program has a number of "loops" it goes through. So, I push data to this array (which is global) a first time, sort it, and then later I clear the array with the .shift() function in conjunction with a for loop. I then push new data to the array with the same line of code mentioned above.But what's happening is this: on the first round, everything works great, and this is what my output looks like:[code]Before I cleared the array with for loop and .shift(), it would say "Northern Alberta & Prairies" in ALL array slots. Since I started using the .shift() function I managed to get BC to remain, but it's still clearing my southern alberta entry.

View 2 Replies

IDE :: CS3 SortOn On Arrays Crashes?

Jul 3, 2010

I'm trying to sort some arrays with the sortOn() function in Flash CS3.. but it always seems to crash itself upon exporting!Do you guys get this too? And is there a way to get around this?

Code:
var ms:Array = [];
ms[0] = [0,1];

[code].....

View 2 Replies

Professional :: Dataprovider SortOn Not Accurate Over 100?

Sep 30, 2010

I've used the sortOn function (dp.sortOn("cost");) to sort my dataprovider values based on cost. It works great until I get values over 100. Then it thinks that 250 < 50.

View 2 Replies

ActionScript 3.0 :: Using SortOn() With Private Properties?

Sep 23, 2010

Is there a way to use the sortOn() method of the Array class to sort an array of objects by a private property?I've tried using a getter function, but Flash didn't like it.It doesn't seem right to leave a property as public, but the sortOn() method is very handy -

View 4 Replies

ActionScript 2.0 :: Using SortOn With Date Objects?

Aug 1, 2007

I have a multidimensional array where the items have Date objects. I 've tried to use Array.sortOn(myDate) with no success. Do I have to convert the Date to a string (like 20070731) to use sortOn correctly?

View 1 Replies

ActionScript 2.0 :: SortOn() Multiple Fields With Different Options

Feb 12, 2005

I get the feeling this problem is anything but complex, but I can't seem to pull it off.

I have an array that contains search results and looks like this:

array[x].id :Number
array[x].sectionID :Number
array[x].occur :Number
array[x].title :String
etc...

I want to sort it by sectionID ASC and occur DESC (occurances). What I read in the documentation is that I can sort on multiple fields like so:

array.sortOn(["sectionID", "occur"], options);

But I need to specify different options for each fieldName while it seems the function only allows for one set of options.

View 8 Replies

ActionScript 2.0 :: Sort With Xml Node Attributes ( With SortOn() )

Apr 27, 2009

I have xml:

Code:
<?xml version="1.0" encoding="utf-8"?>
<articles>
<entry datumNum="20090420" date="20/4/2009" id="1">
<title>Some title</title>

[Code]....

I would like to sort xml nodes using attribute datumNum, but I can't get it to work. Don't know how to pass attribute to sortOn function before the for loop.
Note that there is maybe a error in xml parsing code here, because I tried to be as short as I can.

View 3 Replies

ActionScript 2.0 :: SortOn() Multiple Fields With Different Options?

Feb 12, 2005

I have an array that contains search results and looks like this:

array[x].id :Number
array[x].sectionID :Number
array[x].occur :Number
array[x].title :String
etc...

I want to sort it by sectionID ASC and occur DESC (occurances). What I read in the documentation is that I can sort on multiple fields like so:

array.sortOn(["sectionID", "occur"], options);

But I need to specify different options for each fieldName while it seems the function only allows for one set of options.

View 9 Replies

Flash - Using Array And Loop / Push Function

Apr 2, 2011

what I'm trying to do is to get 4 movieclipps (leaf1, leaf2, leaf3, leaf4) to play the sound that is attached to them when is dragged onto another movieclip (NatureTarget) and the play button is pressed so that the sounds are played in the order they are dragged on. I know I need to use an array and the push function and a loop...

View 1 Replies

ActionScript 2.0 :: Calling A Function With An Array Variable As Arguments Is Resetting Array?

Oct 12, 2006

I'm going to post the full code of the two functions, disregard the "fluff" unrelated to the two functions as it is all working flawless, I've tested this HEAVILY and cannot understand why it keeps setting the entire array to undefined!

Code:
// processReplace Function
function processReplace(transferFiles) {
var processArray:Array = transferFiles.slice();

[Code]....

Basically it's supposed to check to see if the file exists and return as true if it does and add it to a replace array, then the replace array is processed into a single string and put into a dialog box through the flash wrapper prompting them to "replace the files or not".

It makes the replace array just fine, it actually even has the right "count" in it but it's setting all the "filenames" to undefined because of the exists = processSearch function.

I even tried to make a new array and run the search just from that one and set the values from the old one and it's still failing.

Is it because of the "break" or can anyone figure it out? Iknow it's hard because you can't use the code

View 1 Replies

Flash - Lost Spaces In Strings With CSV To Array Function?

Oct 25, 2011

I am working with a function that converts csv data to a multi-dimentional array. I am then going through the characters to find specific situations in the way the strings are handled in the array. One example is if I have a string like - "this is a string, yeah" - then I make sure not to count the comma in the string because it is between quotes from that string. Anyhow In the following function I have some how lost my spaces in the results.Instead of getting "this is AS3" I am getting "thisisAS3". Spaces seem to only be available in the strings that have quotes.

function CSVtoArray(csv:String):Array {
var inQuotes:Boolean = false;
var field:String = "";

[code].....

View 1 Replies

ActionScript 2.0 :: Use Array To Do 3 Flash Buttons With Onclick Function?

Jul 26, 2009

How to use array to do 3 flash buttons with onclick function?

View 1 Replies

ActionScript 3.0 :: Store A List Of Parameters Needed For A Function In An Array And Then Use That In A Function Call?

Jun 23, 2009

is it possible to store a list of params needed for a function in an array and then use that in a funciton call?

[Code]...

or something like that?? Prob have to iterate the array but how do i get the params into the function call? Is this even possible?

View 6 Replies

ActionScript 3.0 :: Function Returning Array And Declaring A Function With Event And Variable?

Jul 27, 2009

is it possible to declare function this way

ActionScript Code:
function startShake(e:MouseEvent, num1, num2):void

what i mean is it possible to send to the function not only en event but also a variable and a second question how can i access

ActionScript Code:
function stopShake(e:MouseEvent):Array

this array that function return.

View 1 Replies

ActionScript 2.0 :: Filling Function Arguments With Array Items, Function.call()?

Feb 28, 2008

I have this code but I cannot work out how to fill in function parameters based on an array and it's length, see line 7

[AS]
import com.robertpenner.easing.Cubic;
MovieClip.prototype.framesTimeout = function(func:Function, frames:Number, args:Array) {

[code]....

Is it possible to call a function and fill in the parameters based on an array and it's length?

View 1 Replies

ActionScript 2.0 :: Pass Flash Array To Javascript Function Without Using Json?

Oct 28, 2009

How do I pass flash array to javascript function without using json?

View 3 Replies

Javascript :: Flash - Pass Array Collection From Flex To Function?

Jul 22, 2011

Is it possible to pass an ArrayCollection object from flex ExternalInterface.call() as a parameter to javascript function?

[Code]...

View 1 Replies

Actionscript 3 :: Rest Argument Array To Another Function As An Object Property In Flash?

Nov 17, 2009

I have a function that uses the ... rest argument as follows:

public function dispatchActions(... actions):void
{
var params:Object = new Object();
params.actions = actions; // I also tried casting ie. = (actions as Array)
this.target.dispatchEvent(new ActionEvent(ActionEvent.dispatchActions, params));
}

I call it using myActionObject.dispatchActions("all"); The problem is that when a listener receives the dispatched params object and try to access the actions array, it does nothing. If I try to trace evt.params.actions it traces blank and if I try to trace evt.params.actions[0] it traces undefined.

ex:

function actionsListener(evt:ActionEvent):void
{
var actions:Array = (evt.params.actions) as Array; // I also tried without casting
trace("actions", actions, "actions 0", actions[0], "action 1", actions[1]);
}

This is the output: actions actions 0 undefined actions 1 undefinedI don't understand why I can't pass the ... rest argument through an object as an event parameter. How can I make this work?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved