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
Similar Posts:
Jun 4, 2011
I've heard it's considered best practice to keep all class properties private and to change them using getter and setter methods.
View 5 Replies
Jul 24, 2010
Why static method cant access private properties in the same class?
View 1 Replies
Oct 22, 2009
how bad is this practice? I am having trouble getting to some stuff so i am taking the easy way out
Code:
private static var _interrupted:Boolean;
public static function setInterrupted(value:Boolean):void{
_interrupted = value;
}
View 1 Replies
Aug 11, 2010
here is a snippet of my code in an as file
ActionScript Code:
class PoolBall extends MovieClip {
private var poolBall:MovieClip;
[code].....
View 4 Replies
May 25, 2011
there are classes definitions where all their methods are private my question is why are they private, because i've tried a code wherein i changed all the private access modifier to public and nothing changed!
what if you make an instance of that class with all its method private, how are you be able to access that on another class. coz i know private methods are only accessible to the class where they are declared! will the instance of that class be able to access the superclass's private methods!
on private variables, it's still not clear to me as to why make a private variable and then use a getter and setter, when you can simply make it public! are these variables called static?cause on the way i understand it private functions and private variables are static?
View 1 Replies
Nov 26, 2006
Okay so you've got your private vars in your AS2 Class, you think they're all safe right? Wrong.
Doing a trace(MyClass.myvar); will spit out an error that the var is private and you can't touch it.
But a trace(MyClass["myvar"]); will work perfectly fine. You can use it normal, without any setters getters outside the class.
Is there a way to protect against this? I think this is a huge security flaw. I know it's simple OOP, but a private var in an object should have rules.
View 7 Replies
Feb 2, 2011
is there a difference between classifying a function 'private' or 'private static' in a singleton? It seems that they both do the same thing. Maybe some difference in performance?
[Code].....
View 10 Replies
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Sep 23, 2006
My multidimensional array is created this way :
Code:
cards_array = new Array()
z=0
[code].....
View 3 Replies
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
Sep 14, 2005
Just been playing around with the tutorials, on the Set properties/Get properties. Everything is all cool, except the "instance name" aspect. I dnt really understand that too well. Is it possible to change an Mc Name dynamically? If you look at my FLA when you hit the top left red button you will get a trace of the mcName as "square". Now if you input a new mc Name on the right hand side, you will see it change on the left hand side. But i want to know why it doesnt remain as the new mc Name, it still goes back to square.
View 3 Replies
Jan 30, 2008
I forgot to put it in the title so I'll just place it here; I am using AS 2.0. I know that there are other ways to accomplish the goal that am after, but I was wondering if anyone knows of a way to access the properties of an object's properties?
Here is the code that I thought of, even though it doesn't work
var a:Object = new Object();
a.bproperty = 0; //lowerlevel properties
a.cproperty = 1; // lowerlevel properties
[Code].....
This really just boils down to how I am organizing the code(I have ideas on what do next, and i am 99% sure that I can get them to work), and if there is a way to dynamically access the properties of the objects properties, It will save me from creating yet another large block of code for my project. If you want to see the unfinished project, go to [URL]
View 3 Replies
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
Jun 9, 2009
I've worked with AMFPHP for a while, but with Adobe supporting ZendAMF, I was wondering if I should migrate.
One of the major disadvantages for AMFPHP is that class mappings need to be public, so not only does that mean public members on the PHP side, but also on the Flex side. I was wondering if it is the same case for ZendAMF.
View 1 Replies