(myArray.length == 0);
 
unless myArray has not been instantiated
 
 
Regards,
 
Bjorn Schultheiss
Senior Flash Developer
QDC Technologies
 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of davcavs
Sent: Friday, 6 October 2006 7:28 AM
To: [email protected]
Subject: [flexcoders] Re: How to determine if an array is empty.

Don't know if this is exactly what you are asking for, but this is
another way to determine the number of results:

private function handleNewProductsResult(evt:ResultEvent):void {
if (evt.result.products == null) {
// there are no results
newProductCount = 0;
}
else if (evt.result.products.product[0] == null) {
// not an array, so there is only one result
// and the result is evt.result.products.product
newProductCount = 1;
}
else {
// is an array with more than 1 result
newProductCount = evt.result.products.product.length;
}
//...
}

-David

--- In [EMAIL PROTECTED]ups.com, "joshuajnoble" <[EMAIL PROTECTED]> wrote:
>
>
> Just a suggestion, but try binding your DG to a seperate object and
> then when the onResult comes back, try/catch through it (using
> try{....}catch{....}), so that if there's only one result you're not
> getting unhandled exceptions. You'll be able to get dowwn to the
> length that way. If there are no problems then set your object to
> evt.result.
> You could also just throw it into an array and then count that.
>
> --- In [EMAIL PROTECTED]ups.com, "greenfishinwater"
> <greenfishinwater@> wrote:
> >
> > I am using HTTPService to return a result set, under normal
> > circumstances there will be 100s of records returned, so I determine
> > the total number of records in this way:
> >
> > This function is called from the result handler of the HTTPService
> >
> > private function handleNewProductsResult(evt:ResultEvent):void {
> > newProductCount = evt.result.products.product.length;
> >
> > But as I discovered if there are no records or only a single record
> > that does not work. So I came up with the following which works:
> >
> > private function handleNewProductsResult(evt:ResultEvent):void {
> > if (newProductListDG.dataProvider != null) {
> > newProductCount = newProductListDG.dataProvider.length;
> > } else {
> > newProductCount = 0;
> > }
> >
> > newProductListDG is the grid that displays the records and is bound
> > directly to getNewProducts.lastResult.products.product
> >
> > getNewProducts is the id of the HTTPService
> >
> > Is there a better way of doing this?
> >
> > Thanks
> >
> > Andrew
> >
>

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to