6 Replies Latest reply on Sep 8, 2010 6:20 AM by Benoitcn

    mosue_over event auto fire issue

    Benoitcn

      I write a mouse_over event handler in a movieclip. But the event fired when the application run automatically even if the mouse out of the application.

        • 1. Re: mosue_over event auto fire issue
          Ned Murphy Adobe Community Professional & MVP

          Show the code.

          • 2. Re: mosue_over event auto fire issue
            Ganesh_Palwe Level 3

            Can you share how you wrote your event handler?

             

            Following works fine for me:

            Create new fla and paste this in the first frame and publish -

             

            var mc:MovieClip = new MovieClip();

            mc.graphics.beginFill(0xFF0000);

            mc.graphics.drawRect(0, 0, 100, 80);

            mc.graphics.endFill();

            mc.x = 80;

            mc.y = 60;

            addChild(mc);

             

            mc.addEventListener(MouseEvent.MOUSE_OVER, mover);

             

            function mover(event) {

            trace(event, mouseX, mouseY);

            mc.x += 10;

            mc.y += 10;

             

            }

            1 person found this helpful
            • 3. Re: mosue_over event auto fire issue
              Benoitcn Level 1
              picContainer->menu->aboutBtn  There isn't code in its parent containers. I just add the code in the menu movieclip to control the aboutBtn.
              
              import com.greensock.easing.*;
              import com.greensock.*;
              aboutBtn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
              aboutBtn.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
              aboutBtn.buttonMode = true;
              
              var po:Point = new Point(aboutBtn.x, aboutBtn.y);
              var p1:Point = this.globalToLocal(new Point(495, 98));
              var p2:Point = this.globalToLocal(new Point(526, 106));
              var tween:TweenMax = new TweenMax(aboutBtn, .5, {bezier:[{x:p1.x, y:p1.y}, 
                             {x:p2.x, y:p2.y}], 
                        ease:Back.easeInOut, overwrite:0
                        /*onStartListener:startHandler*/});
              
              function startHandler(e:Event):void{
              if( tween.reversed ){
                aboutBtn.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
                aboutBtn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
              }else{
                aboutBtn.removeEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
                aboutBtn.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
              }
              }
              function mouseOverHandler(e:MouseEvent):void{
              tween.play();
              }
              
              function mouseOutHandler(e:MouseEvent):void{
              tween.reverse();
              }
              
              • 4. Re: mosue_over event auto fire issue
                Ganesh_Palwe Level 3

                The problem is not with the event handler. Evenif you comment everything inside your event handler the tween is playing.

                 

                Tween happens even after the following modification:

                function mouseOverHandler(e:MouseEvent):void{

                // tween.play();

                }

                function mouseOutHandler(e:MouseEvent):void{

                // tween.reverse();

                }

                1 person found this helpful
                • 5. Re: mosue_over event auto fire issue
                  Benoitcn Level 1

                  Thanks, the problem is the tweenmax run while created !

                   

                  The other problem is how can achieve the effect in this web.

                   

                  http://www.templatemonster.com/flash-templates/30044.html

                   

                  how achieve the buttons roll_over and roll_out effect in flashcs4 ?

                  I can't find the same easing in the motion editor in Flash

                  • 6. Re: mosue_over event auto fire issue
                    Ned Murphy Adobe Community Professional & MVP

                    The line below by itself will play the tween...

                     

                    var tween:TweenMax = new TweenMax(aboutBtn, .5, {bezier:[{x:p1.x, y:p1.y},
                                   {x:p2.x, y:p2.y}],
                              ease:Back.easeInOut, overwrite:0
                              /*onStartListener:startHandler*/});

                    You want to have that specoified on the over event handler function, though you will want to declare it oustide of it if you want to manipulate the tween elsehwere as well...

                     

                    var tween:TweenMax;
                    
                    function 
                    startHandler(e:Event):void{
                         if( tween.reversed ){
                           
                    aboutBtn.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
                           
                    aboutBtn.addEventListener(MouseEvent.MOUSE_OVER, 
                    mouseOverHandler);
                         }else{
                           
                    aboutBtn.removeEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
                           
                    aboutBtn.addEventListener(MouseEvent.MOUSE_OUT, 
                    mouseOutHandler);
                         }
                    }
                      
                    function 
                    mouseOverHandler(e:MouseEvent):void{
                         tween = new TweenMax(aboutBtn, .5, 
                    {bezier:[{x:p1.x, y:p1.y}, 
                                   {x:p2.x, y:p2.y}], 
                              
                    ease:Back.easeInOut, overwrite:0
                              
                    /*onStartListener:startHandler*/});
                    }