Did I understand correctly that you create child2 dynamically? If so, I would 
use the following pattern in the parent's script:

// Create and add child2:
child2 = new Whatever();
addEventListener(...);
addChild(child2);

---

// Remove child2:
removeEventListener(...);
removeChild(child2);

Gordon Smith
Adobe Flex SDK Team

From: [email protected] [mailto:[email protected]] On Behalf 
Of markgoldin_2000
Sent: Friday, January 09, 2009 5:40 PM
To: [email protected]
Subject: [flexcoders] Re: Release a child .... again


On its (child2) creationComplete.

--- In [email protected]<mailto:flexcoders%40yahoogroups.com>, Gordon 
Smith <gosm...@...> wrote:
>
> When does child2 call parent.addEventListener()?
>
> Gordon Smith
> Adobe Flex SDK Team
>
> From: [email protected]<mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected]<mailto:flexcoders%40yahoogroups.com>] On 
Behalf Of markgoldin_2000
> Sent: Friday, January 09, 2009 7:36 AM
> To: [email protected]<mailto:flexcoders%40yahoogroups.com>
> Subject: [flexcoders] Re: Release a child .... again
>
>
> <If you really are doing addEventListener to child2
> No, child2 adds a listener to its parent - the Container. Child1
> dispatches the event, the event bubbles up, Container handles it,
but
> sees that actual event hanlder is in child2 and lets chuld2 handle
it.
> So, where to remove the listener?
> If I have child2.removeEventListener("remoteDateEvent",
> remoteClickHandler); outide of child2 then I am getting an error
> message:
> 1120: Access of undefined property remoteClickHandler
>
> --- In 
> [email protected]<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders%
40yahoogroups.com>, "Paul Andrews" <paul@> wrote:
> >
> > According to your original explanation the only event handler for
> > "remoteDateEvent" is added to the parent container. All the forms
> do is
> > issue events.
> >
> > If you really are doing addEventListener to child2, then
> > child2.removeEventListener("remoteDateEvent", remoteClickHandler);
> >
> > is what you need.
> >
> > removeAllChildren should be done on the parent container.
> >
> > so, first remove handlers, then remove forms.
> >
> > Paul
> >
> >
> >
> >
> >
> > ----- Original Message -----
> > From: "markgoldin_2000" <markgoldin_2000@>
> > To: 
> > <[email protected]<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders%
40yahoogroups.com>>
> > Sent: Thursday, January 08, 2009 7:54 PM
> > Subject: [flexcoders] Re: Release a child .... again
> >
> >
> > >I am not removing the handles at all because I dont know where to
> put
> > > code for that.
> > > I tried (child2)
> > > creationComplete="init();"
> > > ..
> > > private function init():void
> > > {
> > > parent.removeEventListener("remoteDateEvent",
remoteClickHandler);
> > > }
> > > Does not help.
> > >
> > > Children removal is removeAllChildren.
> > >
> > > --- In 
> > > [email protected]<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders%
40yahoogroups.com>, "Paul Andrews" <paul@> wrote:
> > >>
> > >> ----- Original Message -----
> > >> From: "markgoldin_2000" <markgoldin_2000@>
> > >> To: 
> > >> <[email protected]<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders%
40yahoogroups.com>>
> > >> Sent: Thursday, January 08, 2009 7:12 PM
> > >> Subject: [flexcoders] Release a child .... again
> > >>
> > >>
> > >> > Still cannot get it work.
> > >> > Here is my scenario:
> > >> >
> > >> > 1. Container adds child1 to itself.
> > >> > 2. Container adds child2 to itself.
> > >> > Child2 adds a custom event listener to parent (Container):
> > >> > parent.addEventListener("remoteDateEvent",
> remoteClickHandler,
> > >> > false, 0, true);
> > >> > 3. Child1 dispatches a custom event:
> > >> > private function executeRun(event:KeyboardEvent):void
> > >> > {
> > >> > if(event.charCode == 13)
> > >> > {
> > >> > var eventObj:remoteDateRun = new remoteDateRun
> ("remoteDateEvent");
> > >> > dispatchEvent(eventObj);
> > >> > }
> > >> > }
> > >> > 4. Child2 handles custom event:
> > >> > public function remoteClickHandler(event:remoteDateRun):void
> > >> > {
> > >> > runDate = event.runDate;
> > >> > dailyJobSumaryList(lineId);
> > >> > }
> > >> > At this point everything works.
> > >> > Now, after some user action both forms are removed form the
> > > Container
> > >> > and all previous steps are repeated.
> > >> > At this point everything still works.
> > >> > Now user is going back to his initial selection. Both forms
are
> > >> > removed again and 3rd set of forms is added to the Container.
> At
> > > this
> > >> > point if a child1 dispatches a custom event then child2 form
> set
> > > #1
> > >> > will get it to handle. Can someone please just put step by
step
> > >> > instruction how to make sure that a form is released and
> > > collected?
> > >> > I have spent days if not more trying to fix the problem.
> > >>
> > >> Be better if you can make a complete example. You say that
child2
> > > handles
> > >> the event, yet you also say you add the event handler to the
> parent
> > >> container, nor do you show any code to remove the handlers or
the
> > > children.
> > >>
> > >> Paul
> > >>
> > >> > Thanks in advance.
> > >>
> > >
> > >
> > >
> > > ------------------------------------
> > >
> > > --
> > > 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
> > >
> > >
> > >
> >
>

Reply via email to