I seem to be missing something. I tried the suggested way:

public function loginHandler(e:ResultEvent):void {
                userData = e.result as ArrayCollection;
                var object:Object = userData.getItemAt(0) ;
                var firstName:String = object["FIRSTNAME"] ;
                Alert.show(firstName);
            }

and I am getting this error:

TypeError: Error #1009: Cannot access a property or method of a null object 
reference.
    at index/loginHandler()
    at index/___index_Operation3_result()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at 
mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
    at 
mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()
    at mx.rpc::Responder/result()
    at mx.rpc::AsyncRequest/acknowledge()
    at DirectHTTPMessageResponder/completeHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()

How can I  
                change my backend script a bit in order to return an 
ArrayCollection of typed User objects? Any examples?

Also, I normally don't return all user info, but just using '*' till I can get 
this figured out:

Thanks for the help so far 

----------------------------------------

                                From: Fotis Chatzinikos 
<[email protected]>
Sent: Tuesday, January 27, 2009 8:49 AM
To: [email protected]
Subject: Re: [flexcoders] Re: Setting data from web service to  
ArrayCollection. 

Try the following:

userData:ArrayCollection = event.result as ArrayCollection ;

Then it seems that the array contains untyped object (Dictionary/hashmap type) 
so:

userData.getItemAt(0)["FIRSTNAME"] should give you :"Wally" ;

do not have a compiler in hand at the moment ... if the previous line does not 
work for any reason:

var object:Object = userData.getItemAt(0) ;
var firstName:String = object["FIRSTNAME"] ;

PS: I would recomment to change your backend script a bit in order to return an 
ArrayCollection of typed User objects

PS2: Passwords are normally kept on the server and not transfered on the client 
, at least not in text form...

                                                                On Tue, Jan 27, 
2009 at 6:19 PM, Wally Kolcz <[email protected]> wrote:

Using Alert.show(ObjectUtil.toString(e.result)) This is what I got:

(mx.collections::ArrayCollection)#0
  filterFunction = (null)
  length = 1
  list = (mx.collections::ArrayList)#1
    length = 1

    source = (Array)#2
      [0] (Object)#3
        DEPARTMENT = "PRMC"
        FIRSTNAME = "Wally"
        ISACTIVE = 1
        LASTNAME = "Kolcz"
        PASSWORD = "2113"
        POSITION = "Senior ColdFusion Architect"
        ROLE = "admin"
        UNIQNAME = "wkolcz"
    uid = "C7A50498-377F-0EE0-A170-18E1C0C2D677"

  sort = (null)
  source = (Array)#2

How can I set it to userData:ArrayCollection and then call the firstName 
variable?

----------------------------------------
From: Fotis Chatzinikos <[email protected]>
Sent: Tuesday, January 27, 2009 7:42 AM
To: [email protected]
Subject: Re: [flexcoders] Re: Setting data from web service to  
ArrayCollection. 

Why do not you try Alert.show(ObjectUtil.toString(e.result)) //replace e.result 
with e to see the whole event

ObjectUtil is very useful in situation like this as it show a textual 
representation of any object graph 

On Tue, Jan 27, 2009 at 5:37 PM, valdhor <[email protected]> wrote:

Perhaps you have an arrayCollection of arrayCollections (What does the

debugger show as the result type?). You may like to try...

var resultArrColl:ArrayCollection = e.result.source;

var firstResult:ArrayCollection = resultArrColl[0];

Alert.show(firstResult[0]);

--- In [email protected], "Wally Kolcz" <wko...@...> wrote:

>

> I moved my CFC and database to my localhost so I can debug the

webservice output and see it. I am a wee bit confused. The results

panel is saying something like this:

> 

> e --> result --> source --> [0] --> firstName (etc)

> 

> How do I set that local? 

> 

> I tried myData = e.result.source as ArrayCollection and then tried

to trace myData.getItemAt(0).firstName but got an error. 

> 

> ----------------------------------------

> From: "Wally Kolcz" <wko...@...>

> Sent: Tuesday, January 27, 2009 5:30 AM

> To: [email protected]

> Subject: [flexcoders] Setting data from web service to ArrayCollection. 

> 

> I am so trying to wrap my head around web services and use them for

my projects since we Blue Dragon here at the U. I have my CFCs and

they seem to work fine. However, I have no idea on how to set the

'return value' for a web service to an arraycollection to use it. I am

used to RemoteObjects that I can just set and then use

myData.getItemAt(0).name...

> 

> I have a query to my database that returns one row of records

through a web service. It is returned to my Flex app and I am trying

to get it to an ArrayCollection variable for use in the application. I

was watching a Lynda video that uses something like:

> 

> myData = e.result.Tables.Table0.Rows as ArrayCollection. Now is that

how you can set that row's columns at the value of the

ArrayCollections? Or is this only going to work for the video scenerio?

> 

> Thanks for any info!

>

-- 
Fotis Chatzinikos, Ph.D.
Founder,
Phinnovation
[email protected], 

-- 
Fotis Chatzinikos, Ph.D.
Founder,
Phinnovation
[email protected], 

                                                


Reply via email to