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
  

Reply via email to