1
votes

I have an mxml form with several DropDownLists.

Those DropDownLists are loaded with an array collection in this class:

package fr.intersystemes.DataProvider
{
    import fr.internity.config.urlManager;

    import mx.collections.ArrayCollection;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.http.HTTPService;

    public class dpDDLCustomer
    {



        public function dpDDLCustomer()
        {
        }

        public function onFault(event:FaultEvent):void
        {
            trace(this + event.fault.toString());
        }
        public function serviceCustomCivil():ArrayCollection
        {
            var DP_CUS_CIVIL:ArrayCollection ;

            DP_CUS_CIVIL = new ArrayCollection (
                [{label:"Monsieur" , data:"0"},
                {label:"Madame", data:"1"},
                {label:"Mademoiselle", data:"2"},
                {label:"Le Jeune", data:"3"}]

                );

            return DP_CUS_CIVIL;

        }
}

But now I'd like to query the database to load the ArrayCollection. I know how to do that if I place HTTPService and DropDownList in the same MXML file but I don't know how to do if HTTPService is in separate file.

Could you help me?

Thanks

1

1 Answers

1
votes

You need to change things around so that your ArrayCollection is a bindable property on your DpDDLCustomer Class (note that it's considered best practice to name Classes beginning with a capital letter--you might remember seeing a warning to that effect when you created the Class).

Then all you have to do is create a shared instance of that Class (automated Dependency Injection Frameworks such as Robotlegs can make this much easier, but there are other ways--post back of you need help with this) or only share the exposed ArrayCollection variable (again, one shared instance). When the Service returns the information, it populates the shared instance itself or generates an Event that tells a higher up Control component to populate the AC.

I used to have some examples online, but it seems my subdomain is down. I'll try to get to the bottom of it and post back.