2 Replies Latest reply on Aug 12, 2008 12:31 AM by Ludo99

    SelectedItem from a DispatchEvent

      I have been looking into this particular problem for a while and cannot get anywhere with it. I hope someone is able to point me in the right direction.

      I have extracted a Panel and DataGrid into a component and have tried to then dispatch an event whenever anyone selects a row on the datagrid. The Application contains the Panel component and the event is included in the mxml for that component.
      The problem I am having is that (looking at the debugging) the component seems to be dispatching the event with a selectedItem, but the Application does not seem to have any reference to the selectedItem in the event that it receives.

      In the Panel, I have the following code:
      import mx.collections.ArrayCollection;
      public var gridData:ArrayCollection;
      private function sendData(eventObj:Event):void {
      dispatchEvent(new Event("change"));
      [Event(name="change", type="flash.events.Event")]
      <mx:DataGrid dataProvider="{gridData}" id="orderGrid" change="sendData(event)">
      In the Application I have the following reference to the component:
      <comp:orderGridPanel label="List2" width="100%" height="100%" gridData="{myOrders}" change="selectOrder(event)"/>
      ...and the following script that should process the event:
      private function selectOrder(evt:Event):void
      lblClient.text = evt.currentTarget.client;
      "client" is a field on an xml file that is being displayed by the dataGrid.
      I have been trying to get to the bottom of this for ages and have tried innumerable variations on the above code, but nothing seems to get me any closer to seing the selectedEvent.
      If anyone can point out my errors here, I would be most grateful.
      Thanks in advance.