I've recently come across an issue with converting XML to an
ArrayCollection. If my XML has more than one "item" in the
collection and the XML is something like this:
All I have to do in my AS is var ac:ArrayCollection =
However, if I only have one item in my xml :
This won't convert to the ArrayCollection via the AS:
var ac:ArrayCollection =
That causes a runtime error. No runtime error if list is >
I converted my code to accomidate a list of length 1 by the
var newArray:Array =
If there are more than one items in the list (example 1),
then newArray is an array of ArrayCollections with length 1.
newArray.pop() will actually pop off an ArrayCollection, which you
then have to getItemAt(index) to get an Object
If there is only one item, then newArray.pop() will pop off
I don't get it?! Has anyone else run into issues like
Just spent time wresteling with this stuff myself. Still
getting used to it all but I beieve the problem is that a 1 item
list is treated as an "object" not an "array". Since there aren't
multiple indexes in the XML, the array wrapper is disregarded.
Objects can't be assigned directly to an AC, so you have to
convert it to an array using toArray or an event function.
I posted some examples in the FlexBuilder forum that may be