title: How to Modify Sprite Class in ActionScript 3?
body: <p>I want to add some more functionality to Sprite class in ActionScript-3. Basically adding variables and methods. I've got this working solution which I don't like much because I need to reference Sprite by its full path:</p>
  
  <pre><code>package myPackage
  {
      import flash.display.Sprite;
      import myPackage.Sprite;
  
      public class Sprite extends flash.display.Sprite
      {
          public function Sprite()
          {
              super();
              graphics.lineStyle(3, 0xff00ff);
              graphics.drawRect(0, 0, 64, 64);
              doStuff();
          }
  
          public function doStuff(): void
          {
              trace("hello world");
              if (Math.random() &lt; 0.9)
                  addChild(new myPackage.Sprite());
          }
      }
  }
  </code></pre>
  
  <p>Missing imports gave me these errors although Java compiler can deal well without those 2 imports:</p>
  
  <ul>
  <li>Error: Ambiguous reference to Sprite.</li>
  <li>Error: The definition of base class Sprite was not found.</li>
  </ul>
  
  <p><strong>Is there another way to add variables, properties and methods to Sprite and use the new Sprite as class afterwards ? If prototyping, is there a simple and easy example ?</strong></p>