I haven't worked with it, actually, but the Language Reference docs are here: http://livedocs.adobe.com/flex/3/langref/mx/binding/utils/BindingUtils.html
-----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 12:02:11 -0700 (PDT) Hi Maciek, would you have an example for BindingUtils since I will be consuming ClientServices in ActionScript? Thanks. ________________________________________________________________________ From: Maciek Sakrejda <msakre...@truviso.com> To: flexcoders@yahoogroups.com Sent: Wednesday, April 8, 2009 1:46:46 PM Subject: Re: [flexcoders] Re: How can I have my class return an ArrayCollection? At first glance, that looks right. Now you just need to add listeners (for ResultEvent. RESULT since you're just re-dispatching it--although it might be a good idea to create your own event type here) to the ClientServices object. Alternately, depending on how you're using this, since your class is bindable anway, you could simply have the HTTPService result handler update your servicesArray, and dispatch an event stating it's ready. E.g., something like [Bindable(event= "foo")] public function get serviceList( ):ArrayCollectio n { return servicesArray; } and in your ResultEvent. RESULT listener, simply do // as before for each (... { ... } // Ideally, dispatch a custom event type, but this will work dipatchEvent( new Event('foo') ); Then, clients binding to the serviceList( ) getter will automagically see updates as soon as the info arrives--e.g. , something like: <mx:Script> <![CDATA[ var cs:ClientServices = new ClientServices( ); ]]> </mx:Script> <mx:List id="serviceList" dataProvider= "{cs.servicesLis t}"/> This is more useful if you're consuming ClientServices in MXML rather than ActionScript, since in ActionScript you have to go through BindingUtils, which is somewhat more awkward, but it still might be better than manually configuring listeners to ClientServices. .. -Maciek -----Original Message----- From: - - <sailorsea21@ yahoo.com> Reply-to: flexcod...@yahoogro ups.com To: flexcod...@yahoogro ups.com Subject: Re: [flexcoders] Re: How can I have my class return an ArrayCollection? Date: Wed, 8 Apr 2009 09:39:05 -0700 (PDT) My problem wasn't receiving null... I send an HTTPService. The ResultEvent creates an ArrayCollection. I wanted my class to return that ArrayCollection but what is happening is right after my HTTPService is sent, my class returns my ArrayCollection before the ResultEvent has time to fill it... therefore it is null.... I'm now trying to implement an EventDispatcher but am getting a little confused... Does this look right??? : [Bindable] public class ClientServices extends EventDispatcher { private var serviceArray: ArrayCollection; private var serviceXML:XML; public function ClientServices (target:IEventDispa tcher=null) { super(target) ; 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) ; dispatchEvent( event) } ); service.send( ); } } Thanks. ____________ _________ _________ _________ _________ _________ _ From: actionscript_ czar <da...@ducharme. cc> To: flexcod...@yahoogro ups.com Sent: Wednesday, April 8, 2009 12:18:04 PM Subject: [flexcoders] Re: How can I have my class return an ArrayCollection? If you are having problems with it giving you a null object before the ResultEvent function is called then make a function that returns an empty ArrayCollection if it is currently null. Perhaps function getServiceArray( ):ArrayCollection { if( this.serviceArray == null ) { this.serviceArray = new ArrayCollection( ); } return this.serviceArray( ); } If that isn't what you are having problems with, perhaps more specificity could help us help you. --- In flexcod...@yahoogro ups.com, - - <sailorsea21@ ...> wrote: > > 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 <valdhorlists@ ...> > To: flexcod...@yahoogro ups.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( ); > > } > > } > > >