title: Embed bitmap in ActionScript3
body: <p>How can I embed a bitmap in Actionscript 3 and get the BitmapData?</p>
  
  <pre><code>public class MyGame extends Sprite {
      [EMBED(source="Assets/helicopter1.png")] private static var BMClass:Class;
      public function MyGame() {
          var BM:Bitmap = new BMClass();
          var BMData:BitmapData = new BitmapData(BM.width, BM.height);
          BMData.draw(BM)
      }
  }
  </code></pre>
  
  <p>I've tried everything. If I ever try to instantiate the embedded class (<code>new BMClass();</code>) I get this error:</p>
  
  <p><code>TypeError: Error #1007: Instantiation attempted on a non-constructor.</code>. </p>
  
  <p>If I use </p>
  
  <p><code>[EMBED(source="Assets/helicopter1.png")] private static var BMClass:BitmapData;</code> </p>
  
  <p>or something similar the BitmapData is null.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>So I figured out that the embedded data is null, but I can't figure out why. What did I do wrong in the embedding?</p>