As you probably know, the current Flash player fails silently in cases like this, and for Flex 1.X, we made the decision not to add this kind of error handling to the framework because of the effect on SWF size. This situation is likely to change for Flex 2.0.
- Gordon -----Original Message----- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of wcucsd Sent: Tuesday, May 10, 2005 8:45 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Event dispatch question Bingo. Thanks, Matt, that was it. I tested this by (temporarily) putting the addEventListener in broadcastChange() just to be sure that the customComponent was instantiated and it worked. But, it seems like I should have received some kind of feedback from the system. I realize it is a callback, but if the listener object is null, then it should throw some kind of run time exception or if the listener object is not null but just wasn't initialized with the rowChange function yet, then Flex should say "tried to call rowChange function on your customComponent but could not find that function". I did put the handleEvent function into my listener object (for the case where your listener object doesn't have a rowChange function), but it wasn't calling that either. --- In flexcoders@yahoogroups.com, Matt Chotin <[EMAIL PROTECTED]> wrote: > Are you sure the customComponent has been instantiated when you call > addEventListener? > > > > _____ > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of wcucsd > Sent: Monday, May 09, 2005 2: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 > > * To visit your group on the web, go to: > http://groups.yahoo.com/group/flexcoders/ > <http://groups.yahoo.com/group/flexcoders/> > > * To unsubscribe from this group, send an email to: > [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED] subject=Unsubscribe> > > * Your use of Yahoo! Groups is subject to the Yahoo! > <http://docs.yahoo.com/info/terms/> Terms of Service. 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/