;

PDA

Click to See Complete Forum and Search --> : Dispatching Event from embeded swf


next2heaven
08-06-2009, 12:26 PM
How do I send an even from an embeded swf and receive it from the class that called it?

Code the dispatches from account_settings.swf file.
dispatchEvent(new CustomEvent(CustomEvent.ACCOUNT_INFO, {theData:pipeSize.selectedItem.data}));



Code that embeds the item and listens for event
[Embed(source="/assets/account_settings.swf")]
private var _accountSettingsClass:Class;
var _accountSettings:MovieClip = new _accountSettingsClass as MovieClip;
_window.addChild(_accountSettings);
_accountSettings.addEventListener(CustomEvent.ACCO UNT_INFO, getInfo);


(the CustomEvent is just a class that extends the Event and allows me to pass information back and forth with the event)

5TonsOfFlax
08-06-2009, 01:03 PM
I don't see why that wouldn't work. Have you tried it? Are you sure the event is being dispatched?

next2heaven
08-06-2009, 01:52 PM
The dispatch is being called for sure. I can't figure out why it's not 'hearing' it (so to speak).

5TonsOfFlax
08-06-2009, 02:51 PM
Is the event being dispatched before the listener is added? For example, if it is dispatched in the constructor, then there's no chance that the listener has been added yet.

next2heaven
08-06-2009, 02:59 PM
No...I've got it attached to a button. So whenever you click the button it dispatches the CLICK event and in that function it does the dispatching using the customEvent.

5TonsOfFlax
08-06-2009, 03:14 PM
Is your event dispatched directly from the accountSettings document class, or an object within that? You might try setting bubbles=true on the event in the latter case.

Also try catching it within the accountSettings class itself just as a debug, to see if it gets that far.