5 Replies Latest reply: Mar 28, 2011 3:31 PM by kglad RSS

    Why is MouseEvent not a compile-time constant?

    jl2000 Community Member

      Hi - I'm trying to understand AS3 having never really understood AS2.

       

      In a class file I have a button (GameButton) which I want to all the instances act the same. I found this code in a tutorial but when I run it I get the error: "Type was not found or was not a compile-time constant:MouseEvent."  And then it names 2 of my public functions. I cannot see what is wrong so I'm hoping someone here can tell me what's wrong.  Here's all the code in my class file:

       

      package {
         
          import flash.display.MovieClip;
             
          public class GameButton extends MovieClip {
                     
              public function GameButton()  {
                 
                  trace("GameButton has been created");
                  stop();


                  addEventListener(MouseEvent.MOUSE_OVER, hoverOver);
                  addEventListener(MouseEvent.MOUSE_OUT, hoverOff);
              }
             
              public function hoverOver(event:MouseEvent):void
              {
                  this.gotoAndStop(2);
              }
              public function hoverOff(event:MouseEvent):void
              {
                  this.gotoAndStop(1);
              }       
             
              public function setLabel(newLabel:String):void
              {
                  this.buttonLabel.text = newLabel;
              }   
          }
      }

       

      TIA your expertise.

      JL