title: AS3 - Defining functions inside of other functions
body: <p>When adding event listeners and defining their corresponding functions I find myself defining the function in the code of a constructor a lot. Something like this:</p>
  
  <pre><code>package
      {
          public class stuff extends Sprite
          {
              public function stuff()
              {
                  minimizeBtn.addEventListener(MouseEvent.CLICK, minimizeOnClick);
                  function minimizeOnClick(e:MouseEvent):void
                  {
                         //do minimization stuff here
                  }
              }
          }
      }
  </code></pre>
  
  <p>However, there is clearly another option to define it like any other method of the class. Something like this:</p>
  
  <pre><code> package
      {
          public class stuff extends Sprite
          {
              public function stuff()
              {
                  minimizeBtn.addEventListener(MouseEvent.CLICK, minimizeOnClick);
              }
  
              internal function minimizeOnClick(e:MouseEvent):void
              {
                  //do minimization stuff here
              }
          }
      }
  </code></pre>
  
  <p>The second option may not really make sense because the function isn't really a method of the class. But my concern is that the first method will use up extra memory for each instance of the class. Which is the most efficient and correct way to do this and also does the first method take up extra memory or CPU time for each instance of the class?</p>
  
  <p>Thanks!</p>