if there's only one item then flex xml to object conversion doesn't know if
it's an array of items or a string. it defaults to string if there is only
one item. so check if ( stories[i].associated.fKey is String ) // do
something different
or just use e4x like what oleg said.

On Thu, May 27, 2010 at 2:39 PM, Mark <[email protected]> wrote:

>
>
> I must be having some crazy brain cramp right now, I'm having a devil of a
> time with getting a loop to work properly. I have an ArrayCollection that I
> need to get to data a level or two down (root>item>associated>fKey). When I
> loop thru it it's fine unless there's only one item in there.. then I get an
> error. My brain is fried.. can anyone tell me what the heck I'm doing here?
>
> Thanks
>
> Original XML:
> <root>
> <item>
> <id>1</id>
> <associated><fKey>2</fKey><fKey>3</fKey></associated>
> <associated><fKey>2</fKey></associated>
> </item>
> </root>
>
> Loop:
> for (var i:int = 0; i < stories.length; i++) {
> for (var j:int = 0; j < stories[i].associated.fKey.length; j++) {
> trace(i + " " + stories[i].associated.fKey[j]);
> }
> }
>
>  
>

Reply via email to