Hi Wally,

Looking at your question in blue, the simple solution is from your parent app, reference a function in your swf that will set the flag...remember it has to be public for the app to be able to reference it.


(parent document)
var childSWF:SWFLoader = new SWFLoader();
parentDoc.addChild(childSWF);

private function onDelete(event:MouseClick):void
{
   childSWF.setDeleteFlag();
}

(child swf)
private var deleteFlag:Boolean = false;

public function setDeleteFlag():void
{
   deleteFlag = true;
}

HTH,
Adrian


Wally Kolcz wrote:

I thought the child of the parent (main application) would be *up* the chain. The child has to listen and react to the event dispatched by the main application.

"I've got a parent application with a 'delete' button. When it's clicked, I want to set a flag in a child swf, which is loaded via SWF loader. "

------------------------------------------------------------------------
*From*: "Tracy Spratt" <tspr...@lariatinc.com>
*Sent*: Thursday, February 12, 2009 10:16 AM
*To*: flexcoders@yahoogroups.com
*Subject*: RE: [flexcoders] Re: Events and Child SWFs

You are misunderstanding how listeners work. You add the listener to the component that **dispatches** the event, and have it call a method where you want the action to take place.

"parent" just goes up one component. The surest way to do this is to use Application.application.addEventListener().

A bubbling event will hot help you going in this direction (down to the child)

Tracy Spratt
Lariat Services

Flex development bandwidth available

------------------------------------------------------------------------

*From:* flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] *On Behalf Of *stldvd
*Sent:* Thursday, February 12, 2009 1:02 PM
*To:* flexcoders@yahoogroups.com
*Subject:* [flexcoders] Re: Events and Child SWFs

Hi Steve,

But I need the child swf to react, not the parent. So I think the
listener has to be in the child, not the parent.

David

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>, Steve Mathews <happy...@...> wrote:
>
> You are assigning the listener to the wrong object. "this" is your child
> swf, but it is the parent that dispatches the event. Depending on
the rest
> of the app "this.parent" might work. So:
> this.parent.addEventListener("inDeleteMode", deleteModeHandler);
>
> Steve
>
> On Thu, Feb 12, 2009 at 10:44 AM, stldvd <stl...@...> wrote:
>
> > Hi guys,
> >
> > I've got a parent application with a 'delete' button. When it's
> > clicked, I want to set a flag in a child swf, which is loaded via SWF
> > loader.
> >
> > So in the parent app on the button's click event I'm dispatching
an event:
> >
> > dispatchEvent(new Event("inDeleteMode"));
> >
> > In the child SWF's init function I've got this:
> >
> > this.addEventListener("inDeleteMode", deleteModeHandler);
> >
> > And then the deleteModeHandler function (stubbed in for testing):
> >
> > private function deleteModeHandler():Boolean
> > {
> > Alert.show("got it!");
> > return true;
> > }
> >
> > It ain't working. Can someone see what I'm doing wrong?
> >
> > Thanks,
> >
> > David
> >
> >
> >
> > ------------------------------------
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt <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 <https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847>
> > Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo <http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo>! Groups
> > Links
> >
> >
> >
> >
>



Reply via email to