You can pass the reference of the call back function you want to invoke, with the event, and call that reference from the object of the event.
It is more elaborated in my previous post: http://groups.google.com/group/flex_india/browse_thread/thread/1d522c915d67ee12/349a66c8f48cde33?hl=en&q=#349a66c8f48cde33 You can take the concept from here. : Steve On Mar 27, 1:28 am, Vania <[email protected]> wrote: > Hello World: > > I have a big problem. I hope that you may help me =[ > > * Well, i´m working with adobe Flex 3 and flex Builder. > * When i need data stored in database, i use web services. > > * Then i have a class that manipulate call and reception of > information delivered by web services: manipulateWS.as > * when data arrives i launch event for alert to form that need it. > > * Each form has its own class manipulate.as .... > * Many forms can call to the same method (ej: loadCountry of class > manipulateWS.as) > > * when the forms ask data, call manipulateWs.as's method and when data > arrive it listen event. > > Although each form has its own class manipulateWS.as, all listen when > the data arrive, even when it dont call it. > Then the form does incorrect things, because it listen event for other > form..... > > Finally my question is: How can i avoid this situation? How does event > know who call it ? or How does event know whom answer it? > > Thank you in advance..... > greetings!!! > > Here is part of code, for you understand better my problem.... > > ********************************************************** > ********* manipulateWS.as *************** > ********************************************************** > > //register listener of web service's method > ws.loadCountry.addEventListener(ResultEvent.RESULT, > resultLoadCountry); > > //method for ask for information: > public function loadCountry(idCountry:int):void > ws.loadCountry(idCountry); > > //method for manipulate the results: > private function resultLoadCountry(event:ResultEvent):void > { > > //when data arrive... i launch a event for alert that information > is here > var ev:ResultMethodWSEvent; > ev = new ResultMethodWSEvent("resultLoadCountry",true, ""); > > dispatchEvent(ev); > > } > > ************************************************************************* > The class ResultMethodWSEvent.as extends of event, and it need: > - str_nameMethod: the name of method-> resultLoadCountry > - if result Ok or not -> true or false > - aditional data > (optional) > > ************************************************************************* > > ********************************************************** > ********* FormX.mxml *************** > ********************************************************** > //register listeners: > my_managerWS.addEventListener(ResultMethodWSEvent.RESULTADOWS, > manipulateResultMethodWS); > > //manipulating event: > private function manipulateResultMethodWS(ev:ResultMethodWSEvent):void > { > switch(ev.str_nameMethodWS) > { > case 'resultLoadCountry': //do things... > } > > } > > //when i need information: > my_managerWS.loadCountry(idCountry); > > ********************************************************** > ********* FormY.mxml *************** > ********************************************************** > //register listeners: > my_managerWS.addEventListener(ResultMethodWSEvent.RESULTADOWS, > manipulateResultMethodWS); > > //manipulating event: > private function manipulateResultMethodWS(ev:ResultMethodWSEvent):void > { > switch(ev.str_nameMethodWS) > { > case 'resultLoadCountry': //do OTHERS things... > }} > > //when i need information: > my_managerWS.loadCountry(idCountry); > > ***************************************************************** --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/flex_india?hl=en -~----------~----~----~----~------~----~------~--~---

