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


Similar Posts:


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

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

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

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 3.0 :: Making An Array Of Custom MovieClip Objects

Jan 20, 2009

I have an object called MenuButton that extends MoveClip.I want to arrange 8 MenuButton objects in a cirle. The easiest way to do this would be to use a for loop and an array of MenuButton objects.The problem is, I'm not exactly sure how to make an array of objects. I've seen some code online, appears to be AS2 and I need 3. It's also not very clear if it does what I need it to.It would also be cool if I was able to name the buttons sequentially, i.e.: button1, button2, etc. I've seen AS2 code for that, but again it's not too clear if that'll work the same in AS3 and if the code I've seen will do what I need it to.

View 2 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.0 :: Array Of Custom Class - How To AddChild

Aug 18, 2010

I have an array of a custom class. The class includes 3 movieclips that all share the same position. I have 5 items in the array, and in the document constructor I fill them as such:

ActionScript Code:
glassArray[0] = new glasses(spot, beam1, glasses2, "index/nav/aboutus", new Point(156, 400));(different string and point for each of the 5 items)

Here's the glasses constructor:
ActionScript Code:
public class glasses extends MovieClip{ //I am the Constructor.
public var spot:MovieClip;
public var beam:MovieClip;
public var glass:MovieClip;
protected var target:String;
[Code] .....

It then goes on to fill each of those mclips with properties based on the point received. How to addchild from the class, I've got a simple for loop in the document constructor that adds them all in. Everything works, except what I'm seeing is that as each item in the array is added in, it overwrites the previous items' properties. In effect, I can create 5 items and give them each a different position, but when I go to addChild I see that all of them have taken on the position of the 5th one.!

View 2 Replies

ActionScript 3.0 :: Array As Parameter And Custom Class?

Dec 23, 2010

If I set my variables as type MovieClip instead of the type of the class for the MovieClip I am calling them as, will this affect my presentation in any way? Say I have a movieClip Walls with a class definition Walls. Will

var newwall:MovieClip = new Walls(); or
var newwall = new Walls();
be any different than
var newwall:Walls = new Walls();

View 9 Replies

ActionScript 3.0 :: Pass Movieclips In An Array To Custom Class

Dec 11, 2008

I have a custom class that animates a set of movie clips. Something like coverFlow or Carosell. What I want to do is pass a array of all the movie clips to be used by the class. I am not sure an array is the best solution but it makes sense to me. The class will not always know how many movieclips are being passed so with an array I can get the lenght and deal with it. here is the instaciation code of my class mBack and mFront are movie clips on the stage.[code]I get this error Type Coercion failed: cannot convert flash.display::MovieClip@113d2061 to Array.it kinda of makes sense why I got the error but if this is not correct how do I pass a list of mc's to my class.

View 5 Replies

ActionScript 2.0 :: Make A Custom Class Return An Array?

Feb 22, 2009

I'm making a custom class and all my get functions are working fine except the one that returns an array. Here is the code for my class (abridged to the relevant parts):

ActionScript Code:
/*
VolcanicIsland class for Polypelago
Script in progress

[Code].....

How do I get an array to return correctly? Doing trace(VI1.getData()[0]) doesn't work either.

View 1 Replies

ActionScript 3.0 :: Pushing Object To Array In Custom Class?

Dec 29, 2011

how can I push an object from my document class array to an array in my custom class?I have an instance of my custom class in my document class called "Pool".The array in my custom class is called "STOREDBALLS"The array in my document class is called "ballArray"How do I get the object from "ballArray" into "STOREDBALLS"I tried using "Pool.STOREDBALLS.push(ballArray[0])" but it didn't work.

View 3 Replies

ActionScript 2.0 :: Setting An Array As Part Of Custom Class

Sep 1, 2006

i am trying to make a custom class that has a small number of variables but I can't seem to get the array part to work.[code]I can't seem to get it to work. I can set and access the other variables OK its just the array thats giving me problems.

View 2 Replies

ActionScript 3.0 :: Adding Parameter From A Custom Class To An Array?

Jun 16, 2011

In class Main I am instantiating a custom class NavLabel that creates a textField. With in NavLabel I dispatch a custom event CustomEventWithParams on a reference to class Main that passes the parameter theLabelWidth along with it. from with in class Main i can trace the theLabelWidth for each of the instantiated NavLabel objects. I want to hold those values in an array labelWidthArray and then use them to position the NavLabel objects. how can I do this?

class Main

Code:
package
{
import flash.display.*;
import flash.events.*;

[Code]....

View 2 Replies

ActionScript 3.0 :: Accessing Function Of Custom Class That Is Stored In An Array?

Jan 27, 2011

i am making a few object of action script..,what special about this object is that in the contructor function of  this object is that i  make it to send a sprite parameter which will act  as it's parent..,var anObject:myObject = new myObject(parentSprite);and in my main project i used those object and store it in an array after adding it to the stage.i do store it to an array cause i need to be able to refer back to it..everything was fine up until i need to call function inside that object which i already stored in an array. how should i call the function in that object from an array that stored the object?

View 4 Replies

ActionScript 2.0 :: Create An Array Of Objects In A Class File?

Nov 28, 2009

I am trying to create an array of purchases or objects. I have several products that I want to store the users selection to contain the item they selected, price, & quantity. I'm at a loss on how to set this up. Currently the user can select their product and their total price will be displayed in the Cart Total text field but I have no way of storing the data.[code]...

View 0 Replies

ActionScript 3.0 :: TypeError. Create A Class With An Array Of Objects?

Mar 7, 2009

I've been trying to create an Array of Objects in a Class structure, for easy access of the objects from other classes and my .fla file. Unfortunately I keep running into this error:

"TypeError: Error #1034: Type Coercion failed: cannot convert Seed@31161a1 to SeedCollection.
at flowerGame06_fla::MainTimeline/flowerGame06_fla::frame1()"

[code]....

View 3 Replies

ActionScript 3.0 :: Create A Custom Class That Extends The MovieClip Class And Contains A Custom Property Of "marker"

Jan 23, 2010

I am new to AS3, as well as Flash in general, so forgive me if this seems highly elementary. All I am trying to do is create a custom class that extends the MovieClip class and contains a custom property of "marker". I want to be able to use and change the value of this custom property on the timeline for an instance of this class and have it behave just like any other (Ex: this.x ==> this.marker).

[Code].....

View 13 Replies

Actionscript 3 :: Passing Custom Class As Parameter To Custom Class Where Parameter Class Not Constructed?

Jun 16, 2011

I have a custom class being constructed from my main class. In the custom class it has another custom class that is passed in as a parameter. I would like to strictly type the parameter variable but when I do, 'the type is not a compile type constant etc'.This, I understand, is because the custom class used as a parameter has not yet been constructed.It all works when I use the variable type ( * ) to type the parameter.I suspect this is a design flaw, in that I am using an incorrect design pattern.It is actually hand-me-down code, having received a large project from someone else who is not entirely familiar with oop concepts and design patterns.

I have considered using a dummy constructor for the parametered class in my main class but the passed in class also takes a custom class (itself with a parametered constructor). I am considering using ... (rest) so that the custom classes' parameters are optional.Is there any other way to control the order of construction of classes? Would the rest variables work?edit)in main.as within the constructor or another function

var parameter1:customclass2;
customclass1(parameter1);
in customclass1 constructor:

[code].....

View 1 Replies

ActionScript 2.0 :: [FLASH CS5] Custom List Class That Manages Custom List Item Class?

Dec 2, 2011

This is my first time working with a class attached to a movieclip that is nested inside a class attached to a movie clip.I've tested all the properties and methods of PTListItem.as and they work properly but when I try to call them on the list item through PTListTop.as it returns undefined.The end goal is to dynamically load a checklist via a txt file.

View 1 Replies

Actionscript 3 :: Flex 4.5 Not Listening To Custom Event Dispatched In Custom Class?

Nov 4, 2011

I have the following situation:I have an event handler, that displays small messages in my application's statusbar.These messages get passes through by dispatching events from custom components.A simple message could be like "HTTP Error" or so.Now, the main event listener, in the main application file, listens to the event dispatched by any custom component,but seems to refuse listening to events dispatched by custom AS classes.Here is my code for the custom event:

package main.events
{
import flash.events.Event;[code]..

So to sum it all up:

- The event listener listens to the custom event dispatched by any custom component.

- The event listener does not listen to the custom event duspatched by an AS class.

Those who wonder, the event really gets dispatched, that's why I added a trace call.

View 2 Replies

Flex :: Access A Custom Property In A Custom Class?

Jan 25, 2010

I couldn't work it out yet...

package components {
public class templateSelection extends VBox {
static public var tempSelectionBag:Dictionary;

[Code]....

I want to have a custom class tempSelection with a Dictionary as a public accessable property of that class. If I use this code, the compiler tells me:

1046: Typ wurde nicht gefunden oder war keine Kompilierungszeit- onstante:Dictionary

Which translates to:

Type was not found or was not a compile-time constant: Dictionary

View 1 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

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







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