2 Replies Latest reply on Jan 21, 2010 3:26 AM by archemedia

    Flex 3 : Dispatching an event

    kiran7881 Level 1

      Hi
      I am trying to Dispatch an event here .
      My requirement is that , on mouseover event of a Button , i am trying to call  a  Mouse click event type.


      <mx:Button  id="myBtn"  label="Register"  mouseOver="handleMouseOver(event)"/>

       

      public function handleMouseOver(event:MouseEvent):void
      {
      var myEvent:MouseEvent = new MouseEvent(MouseEvent.CLICK);

       

      myBtn.addEventListener(MouseEvent.CLICK,handleClick);            

       

      myBtn.dispatchEvent(myEvent);

       

      }

       

       

      public function handleClick(event:MouseEvent):void
      {       
      Alert.show("Hiiiiiiiiiiiiiiiiiiiiiiii");               
      }

       

       

      This is my own written code and i dont like this way as you can see from the above  code that i am using MouseEvent.CLICK number of times .
      Please tell me how can this function handleMouseOver can be improved

       

      Thanks in advance .