I think Paul is saying that your example didn't do what you said it would do. It seems to leave a listener on the parent, and because your custom event has bubbling=true, the parent listener will get it
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of markgoldin_2000 Sent: Friday, November 07, 2008 10:04 AM To: [email protected] Subject: [flexcoders] Re: removeEventListener I will try to get a sample. But what exactly are you asking for? I am showing how I am adding a custom event listener to a form's parent. And how the form then processes remote event. --- In [email protected]<mailto:flexcoders%40yahoogroups.com>, "Paul Andrews" <[EMAIL PROTECTED]> wrote: > > > ----- Original Message ----- > From: "markgoldin_2000" <[EMAIL PROTECTED]> > To: <[email protected]<mailto:flexcoders%40yahoogroups.com>> > Sent: Friday, November 07, 2008 4:58 PM > Subject: [flexcoders] Re: removeEventListener > > > > Ok, I will try to show some code. > > Form's Init > > > > private function init():void > > { > > > > parent.removeEventListener("remoteDateEvent", remoteClickHandler) > > parent.addEventListener("remoteDateEvent", remoteClickHandler) > > } > > The init function removes the listener then puts the same listener back - > it's totally pointless. > > > private function remoteClickHandler(event:remoteDateRun):void > > { > > // each form has different lineId. It would print twice when a second > > form dispatches custom event. Which is what I am fighting with. > > trace(lineId); > > runDate = event.runDate; > > dailyJobSumaryList(); > > } > > > > Before form is added I am removing all forms from Parent: > > reportParameters.removeAllChildren(); > > where reportParameters is "parent". > > > > > > My custom event object is this: > > public class remoteDateRun extends Event > > { > > public static var remoteDateEvent_SET:String = > > "remoteDateEvent"; > > public var runDate:String = new String(); > > public var lineId:int = 1; > > public function remoteDateRun(type:String, > > bubbles:Boolean=true, cancelable:Boolean=true) > > { > > super(type, bubbles, cancelable); > > } > > override public function clone():Event > > { > > return new remoteDateRun(remoteDateEvent_SET); > > } > > } > > > > custom event is dispatched like this: > > var eventObj:remoteDateRun = new remoteDateRun("remoteDateEvent"); > > var df:DateFormatter = new > > DateFormatter(); > > df.formatString = > > "MM/DD/YYYY"; > > eventObj.runDate = > > df.format(date.selectedDate); > > dispatchEvent(eventObj); > > You've left out the most important part! > > The forms and the event handling.. > > Try and make a small example with the forms - it's always good to build a > small (complete) example to illustrate the problem. > > Paul > > > > > > > > > > > > > --- In [email protected]<mailto:flexcoders%40yahoogroups.com>, > > "Paul Andrews" <paul@> wrote: > >> > >> ----- Original Message ----- > >> From: "markgoldin_2000" <markgoldin_2000@> > >> To: <[email protected]<mailto:flexcoders%40yahoogroups.com>> > >> Sent: Friday, November 07, 2008 4:26 PM > >> Subject: [flexcoders] removeEventListener > >> > >> > >> >I have spent some time trying to understand why removeEventListener > >> > would not remove an event listener. I have a Vbox that at run time > > I > >> > am adding a form to. In init of that form parent.addEventListener > > adds > >> > a listener to VBox. Then I am adding another form. That form is > > based > >> > on same class as first form is. So it adds same listener. But > > fisrt it > >> > parent.removeEventListener. Now, second form dispatches an event > > the > >> > VBox listens to and I see that a handler of that event runs twice. > >> > Once for the current form, then for the previous form that was > > removed > >> > from the VBox before I added second one. Can someone please > > explain > >> > why's that happening? > >> > >> A small code sample is worth a thousand words. > >> > >> > Thank you. > >> > > > > > > > > > > ------------------------------------ > > > > -- > > Flexcoders Mailing List > > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > > Alternative FAQ location: > > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469- 446f-b4cf-1e62079f6847 > > Search Archives: > > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups > > Links > > > > > > >

