Home > AS3, Flex > FLEX/AIR Dispatch Custom Events from Popup or between mxml components

FLEX/AIR Dispatch Custom Events from Popup or between mxml components

Here is the way how we can achieve the thing dispatching custom events between components.

PopUp window:

<mx:script>
dispatchEvent( new Event(MyEvent.MY_DATA_CHANGED, true));
</mx:script>

Other mxml component:

<mx:script>
     private function onClick():void {
       var win:MyForm = PopUpManager.createPopUp(this, MyForm, true) as MyForm;
       win.addEventListener(MyEvent.MY_DATA_CHANGED, onMyDataChanged);
     }
     private function onMyDataChanged(event:Event):void {
       trace("DATA CHANGED");
     }
</mx:script>

MyEvent:

public static const MY_DATA_CHANGED:String = "myDataChanged";

I hope this will help.

Categories: AS3, Flex
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.