0 Replies Latest reply on Apr 19, 2007 1:03 PM by JamesEisenlohr

    Event Bubbling with Custom Event

    JamesEisenlohr
      Hello,

      I have two child components, RecordList (has datagrid in it) and UpdateMember (has form in it). When I click on a record in the datagrid inside the RecordList component, I would like to have the information populate the form in the UpdateMember component. Each record in the datagrid is a Member object returned from a CFC. Although I have no errors, the event is not being received by the UpdateMember component. Here is what I have:

      RECORDLIST COMPONENT

      The datagrid:

      <mx:DataGrid id="membersList" dataProvider="{memberArrayCollection}" height="100%" width="100%" change="processRecordSelection()">
      <mx:columns>
      <mx:DataGridColumn dataField="lastName" headerText="Last Name" />
      <mx:DataGridColumn dataField="firstName" headerText="First Name" />
      <mx:DataGridColumn dataField="userName" headerText="User Name" />
      <mx:DataGridColumn dataField="password" headerText="Password" />
      <mx:DataGridColumn dataField="email" headerText="Email" />
      </mx:columns>
      </mx:DataGrid>

      The function:

      public function processRecordSelection():void {
      var o:ObjectDataEvent = new ObjectDataEvent(membersList.selectedItem, "dgSelectedMember", true);
      dispatchEvent(o);
      }

      The event:

      <mx:Metadata>
      [Event(name="dgSelectedMember", type="events.ObjectDataEvent")]
      </mx:Metadata>

      UPDATEMEMBER COMPONENT

      The functions:
      //called by creationComplete
      public function init():void {
      parent.addEventListener( "dgSelectedMember", receiveDGResultHandler );
      }

      private function receiveDGResultHandler():void {
      Alert.show('Event signal from datagrid received!');
      }

      CUSTOM OBJECT EVENT COMPONENT

      package events
      {
      import flash.events.Event;

      public class ObjectDataEvent extends Event
      {
      public var data:Object;

      public function ObjectDataEvent(data:Object, type:String, bubbles:Boolean) {
      super(type, bubbles);
      this.data = data;
      }

      override public function clone():Event {
      return new ObjectDataEvent(data, type, bubbles);
      }
      }
      }


      Any suggestions would be appreciated!

      Thank you,

      James