5 Replies Latest reply on Jan 12, 2009 8:30 AM by Newsgroup_User

    Dispatch Event for loaded Netconnection datas

    badoumba
      Hi All!
      I made a manager component to retrieve data from database through amfphp.
      When the datas are loaded at the end of the "onResult" function, I dispatch an event "contactLoader"
      Another parent mxml component has an instance of my manager component with a call to a function contactLoader="getData()",
      and then this function calls in turn the getContacts() function of the instantiated manager component to retrieve the datas. Thus I am sure that the datas are correctly loaded by my manager before to retrieve the Array.

      But I would like to refresh this array in case any change has been made in the database. The problem is that the listener is created automaticly by the instance of my manager component and the "contactLoader" already exists once the data are loaded once. I need a way to reload the data in the manager , create a new event once the data are downloaded and then my parent component can call one more time the getContacts function.

      Is it the right way to do that? I'm not skilled enouth to solve that problem. Thanks for your help.
        • 1. Re: Dispatch Event for loaded Netconnection datas
          Level 7

          "badoumba" <webforumsuser@macromedia.com> wrote in message
          news:gk57nf$oak$1@forums.macromedia.com...
          > Hi All!
          > I made a manager component to retrieve data from database through amfphp.
          > When the datas are loaded at the end of the "onResult" function, I
          > dispatch an
          > event "contactLoader"
          > Another parent mxml component has an instance of my manager component with
          > a
          > call to a function contactLoader="getData()",
          > and then this function calls in turn the getContacts() function of the
          > instantiated manager component to retrieve the datas. Thus I am sure that
          > the
          > datas are correctly loaded by my manager before to retrieve the Array.
          >
          > But I would like to refresh this array in case any change has been made in
          > the
          > database. The problem is that the listener is created automaticly by the
          > instance of my manager component and the "contactLoader" already exists
          > once
          > the data are loaded once. I need a way to reload the data in the manager ,
          > create a new event once the data are downloaded and then my parent
          > component
          > can call one more time the getContacts function.

          I'm not sure what the issue is...you can fire a new contactLoader event
          whenever you need to.


          • 2. Re: Dispatch Event for loaded Netconnection datas
            badoumba Level 1
            Hi

            The instance of my Manager Component already creates a listener by the property contactLoader="getData()", and call the getData() function when instanciated. How could I add a listener that I could include in a <mx:Script> and launch a function each time a new contactLoader is fired?

            My main problem is remote access delay. If for example I create a new contact (attached script) , I need to update a datagrid after that. Does my onResult function do it once again? If so how can I intercept it in my Parent component? It seems that my getData() function is not called a second time...


            Thanks
            • 3. Re: Dispatch Event for loaded Netconnection datas
              Level 7

              "badoumba" <webforumsuser@macromedia.com> wrote in message
              news:gk7rag$dos$1@forums.macromedia.com...
              > Hi
              >
              > The instance of my Manager Component already creates a listener by the
              > property contactLoader="getData()", and call the getData() function when
              > instanciated. How could I add a listener that I could include in a
              > <mx:Script>
              > and launch a function each time a new contactLoader is fired?
              >
              > My main problem is remote access delay. If for example I create a new
              > contact
              > (attached script) , I need to update a datagrid after that. Does my
              > onResult
              > function do it once again? If so how can I intercept it in my Parent
              > component?
              > It seems that my getData() function is not called a second time...
              >
              >
              > Thanks
              >
              > public function addContact(cont:Contact):void{
              > connection.call("VPM.addContact",responder,cont.contLastName,
              > cont.contFirstName, cont.contPhone, cont.contEmail, cont.contPosition,
              > cont.contCompany);
              > }

              Have you verified whether the fault and/or result handlers internal to the
              component are firing?


              • 4. Re: Dispatch Event for loaded Netconnection datas
                badoumba Level 1
                I have solved the problem this way: I test the typeof() of the onResult returned Object. I set my php functions to return different things ( strings or Arrays). Then I fire different events depending on the return data.

                Does using only 1 NetConnection object for several functions is the right way to do it?


                Thanks
                • 5. Re: Dispatch Event for loaded Netconnection datas
                  Level 7

                  "badoumba" <webforumsuser@macromedia.com> wrote in message
                  news:gkf15n$muu$1@forums.macromedia.com...
                  >I have solved the problem this way: I test the typeof() of the onResult
                  > returned Object. I set my php functions to return different things (
                  > strings or
                  > Arrays). Then I fire different events depending on the return data.
                  >
                  > Does using only 1 NetConnection object for several functions is the right
                  > way
                  > to do it?

                  If you use RemoteObject instead, you can use responders and/or tokens to
                  help determine which result goes with which call.

                  HTH;

                  Amy