[flexcoders] Access data in an Array Collection??

2007-01-15 Thread malik_robinson

Hi,

I have a cfc that returns this query object to flex.  It seems to
convert it to an ArrayCollection?  Is that correct?

Questions

1. How can I get at the email field in this array?

2. How can I check if the array has a len greater than 0?

I tried:  trace(event.result.email), but that does not work and I assume
because I am not referencing a position in the Array.

I have this private function in my code:

 private function loginUser_result( event:ResultEvent ) : void  {
 trace(ObjectUtil.toString(event.result));
  dispatchEvent( new Event(loadHomePage) );
 }

The above trace() displays this.

(mx.collections::ArrayCollection)#0
   filterFunction = (null)
   length = 1
   list = (mx.collections::ArrayList)#1
 length = 1
 source = (Array)#2
   [0] (Object)#3
 email = [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
 password = test
 userId = 1
 uid = BE12A633-8FC1-2B1B-BFB5-292A1416478A
   sort = (null)
   source = (Array)#2




Re: [flexcoders] Access data in an Array Collection??

2007-01-15 Thread Simeon Bateman

Hey Malik,

To access the email field it looks like you are close.  the problem is
likely a case-sensitivity issue.  If you are using flex builder I would put
a break on the line with the trace, and then inspect the
event.resultproperty.  Then you can see what the field names are in
the arraycollection.

Length is a property of ArrayCollection so you can see the length of the
results by tracing length of the arraycollection.  The only trick is that
event.result is typed as object, so you may need to explain to the compiler
that you know its actually an arraycollection.

var ac:ArrayCollection = event.result as ArrayCollection;
trace(ac.length)


Good Luck.

simeon


On 1/15/07, malik_robinson [EMAIL PROTECTED] wrote:


  Hi,

I have a cfc that returns this query object to flex.  It seems to convert
it to an ArrayCollection?  Is that correct?

*Questions*

*1. How can I get at the email field in this array?*

*2. How can I check if the array has a len greater than 0?*

I tried:  trace(event.result.email), but that does not work and I assume
because I am not referencing a position in the Array.

I have this private function in my code:

private function loginUser_result( event:ResultEvent ) : void  {
trace(ObjectUtil.toString(event.result));
 dispatchEvent( new Event(loadHomePage) );
}

The above trace() displays this.

(mx.collections::ArrayCollection)#0
  filterFunction = (null)
  length = 1
  list = (mx.collections::ArrayList)#1
length = 1
source = (Array)#2
  [0] (Object)#3
email = [EMAIL PROTECTED]
password = test
userId = 1
uid = BE12A633-8FC1-2B1B-BFB5-292A1416478A
  sort = (null)
  source = (Array)#2