Try something like the following (I'm using result here instead of
lastResult, but see what works for you:
 
 
var acResults : ArrayCollection;
 
if (myListRequest.lastResult.records.record is ArrayCollection)
{
            acResults = myListRequest.lastResult.records.record;
} 
else 
{
            acResults = new ArrayCollection();
            acResults.addItem(myListRequest.lastResult.records.record);
}
Alert.show(acResults.length.toString());
 
 
HTH,
 
Steve
 
 
 
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Ben Marchbanks
Sent: 28 November 2006 11:29
To: [email protected]
Subject: Re: [flexcoders] lastResult.records.record.length=null when
there's actually 1
 
Thanks Steve for explaining exactly the root cause.

What method would you recommend to test if the 
result is an array or an object ?

Steve Cox wrote:
> When a result contains only 1 object Flex converts it to an Object not
> an ArrayCollection. Therefore your
> myListRequest.lastResult.records.record is an object and won't have
the
> .length property. When you receive more than 1 record it will be an
> ArrayCollection of objects.
> 
> You'll need to check the type of
myListRequest.lastResult.records.record
> before you do any work with it.
> 
> Hope that helps,
> 
> Steve
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com>
ups.com [mailto:[EMAIL PROTECTED]
<mailto:flexcoders%40yahoogroups.com> ups.com] On
> Behalf Of Ben Marchbanks
> Sent: 27 November 2006 19:21
> To: [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com> ups.com
> Subject: Re: [flexcoders] lastResult.records.record.length=null when
> there's actually 1
> 
> myRequest.event.result.length ??
> 
> Not sure I understand how to use event.result to 
> get the count of the records returned.
> 
> Tracy Spratt wrote:
>> And avoid using lastResult except for binding. 
>>
>>
>>
>> Instead use event.result.
>>
>>
>>
>> Tracy
>>
>>
>>
>> ________________________________
>>
>> From: [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com>
> ups.com [mailto:[EMAIL PROTECTED]
> <mailto:flexcoders%40yahoogroups.com> ups.com] On
>> Behalf Of Iko Knyphausen
>> Sent: Friday, November 24, 2006 10:43 PM
>> To: [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com> ups.com
>> Subject: RE: [flexcoders] lastResult.records.record.length=null when
>> there's actually 1
>>
>>
>>
>> Does it behave the same if you use "e4x" as resultFormat?
>>
>> ________________________________
>>
>> From: [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com>
> ups.com [mailto:[EMAIL PROTECTED]
> <mailto:flexcoders%40yahoogroups.com> ups.com] On
>> Behalf Of pdflibpilot
>> Sent: Friday, November 24, 2006 5:35 PM
>> To: [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com> ups.com
>> Subject: [flexcoders] lastResult.records.record.length=null when
> there's
>> actually 1
>>
>>
>>
>> I use the following to get a count of the records returned by
>> HTTPService request.
>>
>> myListRequest.lastResult.records.record.length;
>>
>> When theres only 1 the result is null ? Otherwise the count is fine
>> whenever it is 2 or more. Is this the expected result ??
>>
>>
>>
>>
> 
> 
 

Reply via email to