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


Similar Posts:


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 :: Sort An Array Composed By Alphanumeric Strings?

Jan 14, 2012

I have an array in which the elements have like ID value "imm1", "imm2", "imm3"..."imm10"

the problem is that the sortOn method consider "imm10" lower than "imm2" because it consider 1 and 0 separatly. Then I tryed to write[url]...

but it don't apply the order correctly and I don't know why... maybe because my ID propriety have an alphanumeric value?[code]...

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 :: 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

Flash :: Array That Holds An Object And A Related Value?

Dec 12, 2011

I'm writing a game that involves cargo, and I plan to have a large number of cargo types. Currently I have a Cargo class, and a ship carrying cargo has an array of the Cargos it is holding. I'd really rather not have each ship with a bunch of objects when all I really want to know is how much of which cargoes each ship has. Especially when these ships will be created and discarded a lot.

I'm sure the thing I'm looking for is so basic I'll look dumb for even asking, but I know there's something similar to an array that holds an object and a related value. I want to use that to reference the Cargo type from the static array, and hold the quantity.

What's it called? How would I use it (ie what are common functions used for it)? Some code snippets and terminology would be ideal.

View 2 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 2.0 :: Return An Array That Holds The Values That Were Contained Within An XML Node

Aug 30, 2006

have this code that's supposed to return the an array that holds the values that were contained within an XML node.

[Code]...

for some reason, the code won't return anything. the output just says "undefined". Would a good workaround consist of putting the return function within a setInterval method?

View 3 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 :: 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

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 3 :: Object Pool - Create Ball Objects When The User Holds Down The Mouse Stops When User Lifts Up Mouse?

Dec 24, 2011

I've been reading a lot about the benefits of Object Pooling. Found some "tutorials" online, all above my skill level. Can anyone please show me an extremely simple example of an Object Pool. What my game does is creates Ball objects when the user holds down the mouse, stops when user lifts up mouse. I need to store these Ball objects in an array(or Vector), and hit test them with other objects, removing them from the stage when the hit another object. I'd like to create a pool of say 20 of so, created once, and recycle them.

[Code]...

View 1 Replies

JavaScript :: Passing Alphanumeric Value To URL QueryString Not Working

Feb 9, 2012

I am having a flash application where I want to send parameters to it via the javascript from a defaul.aspx page. I have a parameter called Id where it can accept alphanumeric values. The query string in the url works fine if I enter just numbers for the Id, and takes me to the specific page related to that id , but if I enter a combination of numbers and characters like 001A , it does not work.

This is the code I used
<script type="text/javascript">
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0; i<vars.length; i++) {
[Code] .....

And then passed the flashvars into swfobject.embedSWF. I also don't want to change anything in my mxml files in flash side.

View 1 Replies

Javascript :: Flashvars Not Working With Alphanumeric Value Read From Url

Feb 10, 2012

I have a problem with flashvars , when I read the url from browser if I have assigned just numbers to Id (my paramter in url) ,everything works fine, but if my id includes character, then it does not work , I don't want to change anything in flash side in mxml files, I want to do it with javascript

here is my code

<script type="text/javascript">
function getQueryVariable(variable)
{

[Code]....

View 1 Replies

ActionScript 2.0 :: Alphanumeric Keypad Input (T9) In TextArea

Apr 10, 2010

I have a project that involves taking user input from a keyboard/numeric keypad. The script I wrote detects when the user actually enters a numeral in the text area, and replaces it with step-by-step with a series of letters and numbers in a similar fashion to keypad input on a phone. Everyone else's solution assumes that the user is A.) On an actual mobile device, and B.) That the LAST character is the one that should be replaced in the series.

Whereas, in my case, the user can use standard keyboard/numeric keypad input. Moreover, the caret should be able to move to any arbitrary position within a given string of text, and not just to the end of that string. My script works for the most part, except for some reason, the caret advances on its own without me/the user telling it to, and from what I can see, there's nothing in the code to allow for this:

Code:
var _1:String = "1@._-";
var _2:String = "2abc";
var _3:String = "3def";
var _4:String = "4ghi";
var _5:String = "5jkl";
[Code] .....

Lastly; my code does not account for when a user presses a DIFFERENT number than the one that they are currently pressing--in which case the caret should naturally advance automatically to allow for a new numeral to be inserted. My example is attached.

View 2 Replies

ActionScript 3.0 :: Does Setting An Array Of Objects To Null Erase The Objects From Memory

Apr 27, 2010

I have an array of temporary objects created in a for loop. The objects are of type class "Tile", a class I created. However, it appears that whenever I create a lot of tiles in the for loop, the program slows down indefinitely.

While the array is whiped at a later trigger point, I am thinking that perhaps these Tile objects are not being erased from memory. They are being created on the fly in a for loop, and the array is being reset to "array = []".

Are the objects still in memory or are they cleaned up when the array is set to []?

View 3 Replies

Flex :: Converting Array Of ObjectProxy Objects To Custom Objects?

Jun 10, 2011

I have a service which returns an Array of ObjectProxy objects. I would like to cast this to a custom object (a value object) and create an ArrayCollection. How can I do this?ited:I am using Django and PyAMF for the backend. I had to write a custom SQL query and I am wrapping the resulting records in ObjectProxy and sending the whole result as an ArrayCollection.Here is my client side code:

[ArrayElementType("SessionVO")]
[Bindable]
private var _list:ArrayCollection;

[code]....

View 2 Replies

Regex Validation Expression For Password That Allows For Only Alphanumeric Values

Apr 19, 2010

I'm trying to setup a RegexpValidator that only accepts a string of alphanumeric characters between 6-30 characters long and requires one number. I'm new to Regular Expressions and everything I've tried seems to keep returning an invalid ValidationRsultEvent.[code]

View 2 Replies

Flash :: Recycle Objects When Creating An Array Of Objects?

Dec 18, 2011

Is this the correct, most efficient way to recycle objects when creating an array of objects?

package com {
public class CreateList extends MovieClip {
//this is the object I will be recycling
private var newProperty:PropertyRow;
//this is the array I will use to reference the objects

[Code]...

View 2 Replies

Flash :: Sorting An Array So That 3 Types Of Objects Are Evenly Distributed Throughout The Array?

Oct 17, 2011

iSo let's say I have three different arrays of objects, and I want to combine them into one sorted array. I want the order to be such that the items from each array are evenly distributed throughout the sorted array.

If there were 3 xItems, 3 yItems, and 3 zItems, the sorted array would have this order: x, y, z, x, y, z, x, y, z

HOWEVER, even if the arrays are differing lengths, I still need to make them alternate as much as possible. If there were 6 xItems, 4 yItems, and 2 zItems, the sorted array should have this order: x, y, x, y, x, z, x, y, x, y, x, z

View 1 Replies

Javascript :: Flash - Passing An Array Of Objects Instead Of An Array Of Arrays?

Jul 13, 2010

I'm passing a Javascript Array() to Flash via FlashVars but Flash complains. Can you guys point me what am I doing wrong here?

javascript code
// array with the user defined cities
var usercities = new Array(

[code]......

View 3 Replies

ActionScript 3.0 :: Mergin Arrays - Add All The Objects In The Second Array To The End Of The First Array?

Feb 4, 2010

i have two arrays of DesplayObjects and i want to add all the objects in the second array to the end of the first array, i knew that i just can just do a loop and puch em into the array, but i wondered if there was a simple function for doing this?

View 3 Replies

Actionscript 3 :: Converting Array Of Objects To Array Of Arrays?

Sep 2, 2010

I have a Array of objects which is something like this :

SomeObject (Array)
[0] (object)
id = 1

[code].....

View 4 Replies

Flash Using Xml As Database That Holds Value Of Name Of User

Jul 24, 2011

Does anybody knows how to use the XML as a holder for the values that will be given by the user for example. Parent's name: _. then whatever the user's input i should move that and hold that by the xml. i just dont how. i read lot of books but i can't find any answer. This is for my senior project.URL...

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

Flash :: AS3 Add Movie Clip To Stage Using Variable Which Holds The MC Name

Dec 1, 2010

how to add a movie clip to the stage from the library but i'm strugling to do it when the I need to load a movie clip from the library when the name of the movie clip is held in a variable.

for(var i:Number = 0; i < 64; i++)
{
var blueIconS:blueIcon = new blueIcon();
addChild(blueIconS);

[Code]....

The above code works for adding the blueIcon but I have a variable in that loop which tells which icon to load.

sectorsMCs[jewelsIDs[i]]

The above will tell me what MC name to load but how do I load a MC from library by that variable value?

View 1 Replies

ActionScript 3.0 :: Creating A Library That Holds A Bunch Of MyObjects?

Nov 13, 2009

im creating a library that holds a bunch of myObjects. I 'register' these objects and give them a label(String) so I can access them later. There's 2 ways I can do this easily:

[AS]var libraryictionary = new Dictionary();
//set reference (takes MyObject)
library[myObject.label] = myObject;
//get refernce (takes string, returns myObject)
return library["label"][/AS]

[Code]...

View 1 Replies







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