Are you sure the customComponent has been instantiated when you call addEventListener?

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of wcucsd
Sent: Monday, May 09, 2005 2:45 PM
To: [email protected]
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

Reply via email to