[flexcoders] Re: Result to ArrayCollection - somtimes node is single, sometimes it's an array

2007-02-28 Thread greenfishinwater
This works for me:

if (event.result.price_sets.price_set is ArrayCollection) {
  arr = event.result.price_sets.price_set.source;
} else {
  arr = [event.result.price_sets.price_set];
}

arrCol = new ArrayCollection(arr);

Andrew

--- In flexcoders@yahoogroups.com, darylgmyers [EMAIL PROTECTED] wrote:

 When I use an HTTPService result as an ArrayCollection, certain nodes 
 will be set as a single item or an array depending on the number of 
 items in the node.  Is there a simple way to always force a node to an 
 array regardless of how many items there are?





Re: [flexcoders] Re: Result to ArrayCollection - somtimes node is single, sometimes it's an array

2007-02-28 Thread leds usop
If the result format is set to object... or not set at
all (default is object), the result will be wrapped by
an ObjectProxy if there's a single node. Hence
Andrew's solution should do the trick.  However, in my
case, to ensure that I can indeed use it as an array i
do:

ArrayUtil.toArray(event.result.SomeNode);

then assign that to arr if its a valid array (or throw
an error if not). then set arr as the source of the
new arraycollection. 


--- greenfishinwater [EMAIL PROTECTED]
wrote:

 This works for me:
 
 if (event.result.price_sets.price_set is
 ArrayCollection) {
   arr = event.result.price_sets.price_set.source;
 } else {
   arr = [event.result.price_sets.price_set];
 }
 
 arrCol = new ArrayCollection(arr);
 
 Andrew
 
 --- In flexcoders@yahoogroups.com, darylgmyers
 [EMAIL PROTECTED] wrote:
 
  When I use an HTTPService result as an
 ArrayCollection, certain nodes 
  will be set as a single item or an array depending
 on the number of 
  items in the node.  Is there a simple way to
 always force a node to an 
  array regardless of how many items there are?
 
 
 
 



 

Have a burning question?  
Go to www.Answers.yahoo.com and get answers from real people who know.