I have an XMLListCollection that is populated from a database
that contains census data. Each entry is a person with a race,
occupation, marital status, family size, and year. I want to make
an array of either objects or strings (I don't really care, as long
as it works) where each entry in the array is a unique field value.
For instance, if my database contains people that have family sizes
of 3, 4, 5, 4, 4, 3, 4, and 5, then I want my array to have 3
values, 3, 4, and 5. Right now, the code doesn't deal with
duplicates, but once I have it so that it makes an array of strings
of the values themselves I'll deal with the duplicates. The
database is initially loaded into the stats XMLListCollection.
To accomplish this, I have the attached code.
The display is as follows: The first label outputs 27, which
is correct since that's how many items I have to put in the array.
The list is populated correctly, with all the years displaying as
they should. The popupmenu is empty, which boggles my mind. And
finally the length of the years array outputs as 0. I am very, very
confused as to why any of this happens. Help, please.
The problem you are running into is because you are using an
Array instead of an ArrayCollection. Arrays do not broadcast
updates when there data changes which is the biggest advantage in
my opinion of why you would want to use an ArrayCollection. Example
as follows to illustrate my point.