2 Replies Latest reply on Aug 5, 2008 8:29 PM by g-s-b

    Creating a custom event in Flex

    wkolcz Level 1
      I thought I would start the thread since it was going no where and I think I had the code wrong and no one was telling me that.

      Scenerio:
      I have an application (projectmanager.mxml) that uses a component (liveproject.mxml). The liveproject.mxml uses the PopUpManager to spawn a TitleWindow component (addProject.mxml). I need to create a custom even in the addProject.mxml to dispatch and bubble out so when it closes the liveproject.mxml hears it and reloaded the data in a project datagrid.

      I created the dispatch event with dispatchEvent(new Event("projectInserted", true)); which should broadcast a custom event called 'projectInserted' and have it bubble out. Here are my questions:

      1.) How can I write a custom event called 'projectInserted' in the addProject.mxml that broadcasts before the pop up window closes.

      2.) How do I add an event listener to my initApp() (which is called on creationComplete).

      3.) Where does this go?:
      <mx:Metadata>
      [Event(name="projectInserted", type="flash.events.Event")]
      </mx:Metadata>

      on addProject.mxml or liveproject.mxml?

      I want to understand this, but all the examples I find are for custom events being called on the same component. (In this case the addProject.mxml's form were also on liveproject.mxml) I need the pop up (addProject) to broadcast to liveproject to have it reload/refresh the datagrid with the new project created.

      Thanks