So you want a function to return a result before it's there? I think you can see the problem inherent in that design.
In a runtime other than Flash, you could block if the user calls the function before the result is available, but Flash won't let you do that (and for good reason--the entire paradigm is built around nonblocking actions). I think the only think you can do is have Services extend EventDispatcher and dispatch an event when the result is returned, and listen for that in the client. -Maciek -----Original Message----- From: - - <sailorse...@yahoo.com> Reply-to: flexcoders@yahoogroups.com To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Re: How can I have my class return an ArrayCollection? Date: Wed, 8 Apr 2009 08:35:32 -0700 (PDT) I tried that but it returns an empty ArrayCollection because it's only created within the ResultEvent Function once the HTTPService is successful... Thanks. ________________________________________________________________________ From: valdhor <valdhorli...@embarqmail.com> To: flexcoders@yahoogroups.com Sent: Wednesday, April 8, 2009 11:20:44 AM Subject: [flexcoders] Re: How can I have my class return an ArrayCollection? Umm.. Add a public function that returns serviceArray ? --- In flexcod...@yahoogro ups.com, "sailorsea21" <sailorsea21@ ...> wrote: > > Hi everyone, > how can I have this following class return me an ArrayCollection whenever I call it???? > > [Bindable] > public class Services > { > public var serviceArray: ArrayCollection; > public var serviceXML:XML; > > public function getServices( ):void > { > var service:HTTPService = new HTTPService( ); > service.url = "test.php"; > service.useProxy = false; > service.method = "POST"; > service.resultForma t = "e4x"; > service.showBusyCur sor = true; > service.addEventLis tener(ResultEven t.RESULT, > function (event:ResultEvent) :void > { > serviceArray = new ArrayCollection( ); > serviceXML = event.result as XML; > var ourxml:XML; > for each(ourxml in serviceXML.elements ()) serviceArray. addItem(ourxml) ; > } > ); > service.send( ); > } > } >