Hi,

I was wondering if there are any quick ways to solving this, quick as in CPU
time, not developer time...

I have an Array Collection of VO's called contact which has two
properties...

var myAC : ArrayCollection = new ArrayCollection();

var myContact : Contact = new Contact();
myContact.name = "bob";
myContact.age = 30;

myAC.addItem(myContact);

var myContact : Contact = new Contact(); // Also, Is this bad practice? Am I
loosing the reference to previous myContatc? I'm sure someone mentioned this
to me once on this list?
myContact.name = "bill";
myContact.age = 31;

myAC.addItem(myContact);

var myContact : Contact = new Contact();
myContact.name = "sarah";
myContact.age = 28;

myAC.addItem(myContact);


I now want to write a function which takes the ArrayCollection to scan, the
name property value of the object and it will return the age property of the
first found VO. At the moment, I'm just looping through the collection
without sorting them and it all seems to work. I've had a look at the Array
API and have found sortOn and lastIndexOf(), etc but am thinking is there a
time benefit in sorting first and then looping or is there a super function
that does exactly what I want and super efficient?

I was thinking is it worth converting to XML then using E4X queries but the
conversion is probably time comsuming.


In reality myAC will be about 300 elements so maybe a brute force looping
scan might be good enough but having started this, I'd like to hear what you
others think.


Thanks in advance,
Nick

Reply via email to