You can't cast ("as") unless the variable is an object that contains an
instance of what you are casting to.  HTTPService will not be returning
an ArrayCollection.  It is probably an Array, assuming you have left the
resultFormat at its default "object". (this is usually bad, but that is
a different story)

 

You probably want something like:

var aResult:Array = ResultEvent( data ).result.images;

trace(aResult.length); //what you expect?

var ac:ArrayCollection = new ArrayCollection(aResult);

 

Tracy

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: Wednesday, July 09, 2008 8:00 PM
To: flex
Subject: [flexcoders] Putting returned xml data into ArrayCollection
using Cairngorm framwork (Command Class/Delegate Class/IResponder)

 

I am using an httpService to grab some xml data. Using the Cairngorm
framework, I have the results sent back to the Command Class
(implementing IResponder) from the Delegate Class. As simple as this
might sound, it's frustrating me beyond belief ... what's the simplest
way to put the returned data into an array collection? If I trace out
the returned data (see code), I get an object. However, if I attempt to
put the returned data in an object, it traces out 'null'.

public function result(data:Object):void{            
            
            trace(ResultEvent( data ).result.images) // traces object
            var ac:ArrayCollection = ResultEvent( data ).result.images
as ArrayCollection
            trace(ac) // traces null
}

Can someone shed some light on the error of my ways?

Thanks in advance.

 

Reply via email to