When you click a button, you generate a mouseEvent, so your function should look like...
private function onHelpClicked(event:MouseEvent):void and your button should take this into account... <help:HelpButton click="onHelpClicked(event)" /> event is one of those keywords that Flex automatically understands. Another way (perhaps) is this... <help:HelpButton click="dispatchEvent(new HelpEvent(HelpEvent.HELP_INITIALIZED, true))" /> --- In [email protected], "Jason" <[EMAIL PROTECTED]> wrote: > > So I have a simple component which is a help button, (the component > is mainly just an image.) I wrote a custom event (extends Event) for > use all over my app when a help event occurs, like a request to > launch help. I want to just dispatch this custom event when my > custom help button is clicked, so this is my setup: > > in the script tag: > > import myPackage.blahblahblah.event.HelpEvent; > > private function onHelpClicked():void > { > dispatchEvent(new HelpEvent(HelpEvent.HELP_INITIALIZED, true)); > } > > then later in the MXML: > > <help:HelpButton click="onHelpClicked()" /> > > But the problem is, I get a runtime error when the component is > clicked, "Type Coercion failed: cannot convert > com.venice.event::[EMAIL PROTECTED] to flash.events.MouseEvent." > > If I don't dispatch my custom event, it runs fine. > > Why and how can I fix this? I just want to dispatch a custom event > when the component is clicked on. > > Also, one thing I have never understood about mixing MXML and > Actionscript, is why, when you assign a method to run when something > is clicked on, you don't do this: > > <mx:Script> > <![CDATA[ > private function onMyButtonClick(event:MouseEvent):void > { > //do stuff > } > ]]> > </mx:Script> > <mx:Button click="onMyButtonClick()"/> > > Why don't you put in (event:MouseEvent) as an argument for that > method like you do with other handlers in Actionscript, but not when > the method is called from MXML? > > Thanks > > Jason >

