0 Replies Latest reply on Feb 28, 2010 10:42 PM by Leela RamaKrishna

    Writing a custom event for mouseenter in ActionScript 2.0

    Leela RamaKrishna

      Hi All,


      I am trying to implemetn one functionality based on the mouseenter


      Unlike the mouseover() event, the mouseenter() event only  triggers when the the mouse pointer enters the selected element. The mouseover()  event is triggered if a mouse pointer enters any child elements as well.


      In jquery latest they added support for mouseenter , i want to do the same in Flash AS2.0


      There are only RollOver,RollOut, mousedown, so i want to add mouseEnter event Just like Jquery which is done below


       Checks if an event happened on an element within another element
      // Used in jQuery.event.special.mouseenter and mouseleave handlers
      var withinElement = function( event ) {
           // Check if mouse(over|out) are still within the same parent element
           var parent = event.relatedTarget;

           // Firefox sometimes assigns relatedTarget a XUL element
           // which we cannot access the parentNode property of
           try {
                // Traverse up the tree
                while ( parent && parent !== this ) {
                     parent = parent.parentNode;

                if ( parent !== this ) {
                     // set the correct event type
                     event.type = event.data;

                     // handle event if we actually just moused on to a non sub-element
                     jQuery.event.handle.apply( this, arguments );

           // assuming we've left the element since we most likely mousedover a xul element
           } catch(e) { }

      // In case of event delegation, we only need to rename the event.type,
      // liveHandler will take care of the rest.
      delegate = function( event ) {
           event.type = event.data;
           jQuery.event.handle.apply( this, arguments );

      // Create mouseenter and mouseleave events
           mouseenter: "mouseover",
           mouseleave: "mouseout"
      }, function( orig, fix ) {
           jQuery.event.special[ orig ] = {
                setup: function( data ) {
                     jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
                teardown: function( data ) {
                     jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );





      So please help me in implemeting the customevent mouseenter  I am using AS2.0