title: AS3 / Flash - Add event listener in custom class of a button - Error 1061
body: <p>I'm getting an error whilst trying to add an event listener to a class of a Button on my stage.</p>
  
  <blockquote>
    <p>1061: Call to a possibly undefined method addEventListener through a reference with static type Class.</p>
  </blockquote>
  
  <p>On my stage i have a Button with the instance name stopBtn, this is also exported to an actionscript class called classes.stopBtn (stopBtn.as in a folder called 'classes'). The button is on the first keyframe in the main timeline, in a layer with other buttons on that layer</p>
  
  <p>The error is on line 10 of the stopBtn.as file:</p>
  
  <pre><code>package  classes {
  
      import flash.display.SimpleButton;
      import flash.events.MouseEvent;
      import flash.display.MovieClip;
  
      public class stopBtn extends SimpleButton {
  
          public function stopBtn() {
              stopBtn.addEventListener(MouseEvent.CLICK, stopButtonFunction); 
          }
  
          function stopButtonFunction(event:MouseEvent):void  {           
                  MovieClip(root).trackPosition = 0;
                  MovieClip(root).mySoundChannel.stop();
                  MovieClip(root).playPause.gotoAndPlay(2);
          }   
  
      }
  
  }
  </code></pre>
  
  <p>I have found many threads for the error code 1061 but non of them seem to relate to my problem!</p>
  
  <p>I have tried to ensure all event types are imported by using</p>
  
  <pre><code>Import flash.events.*; but this makes no difference.
  </code></pre>