I think you should use the datagrid id instead of "this" when you define
the listener:
myDataGrid.addEventListener("rowChange", customComponent);

Tracy

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of wcucsd
Sent: Monday, May 09, 2005 5:45 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Event dispatch question


I have an application that contains a datagrid and a custom 
component.  I want to notify the custom component that the user has 
changed rows in the grid.  The application has some associated 
ActionScript.  In the ActionScript, I setup the listener as follows:

  this.addEventListener("rowChange", customComponent);

When the user does a mouseUp on the datagrid, I have it do this:

function broadcastChange()
{
        dispatchEvent({type: "rowChange"});
}

And, in the custom component, I have this function:

function rowChange() : Void
{
        if (dataObject.hasNote() == true)
                detailViewNoteButton.enabled = true;
        else
                detailViewNoteButton.enabled = false;
}

The problem is that, while the dispatchEvent is called correctly, 
the custom component's rowChange function never gets called.  Any 
ideas why?  The custom component is declared as follows in the 
<mx:Application> MXML:

 <mx:Canvas id="topCanvas" width="100%" height="55%">
    <CustomComponent id="customComponent" 
        dataObject="{grid.selectedItem}" 
  </mx:Canvas>

It works fine if I make a local object the object listener instead 
of the custom component as in 

   var listenerObject = new Object();
   listenerObject.rowChange = function(event)
   {
     // handle event
   }
   this.addEventListener("rowChange", listenerObject);

It's almost like the addEventListener doesn't know about the 
customComponent instance...

Thanks,
-Will





 
Yahoo! Groups Links



 






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to