title: Set dimensions of a loaded image in Flash
body: <p>How do I set the width and height of a loaded image in Flash? Setting the dimensions immediately after requesting it does not work. The width and height remain zero.</p>
  
  <pre><code>var poster:Loader = new Loader();
  Stage.addChild(poster);
  poster.load(new URLRequest('http://example.com/image.jpg'));
  poster.width = 320;
  poster.height = 240;
  trace(poster.width); // 0
  trace(poster.height); // 0
  </code></pre>
  
  <p>If I wait a short moment and then set the dimensions, it will work. </p>
  
  <p>I tried listening for the <code>Event.INIT</code> event and <code>Event.COMPLETE</code> events before resizing as suggested by some tutorials. Neither of the events were  triggered.</p>
  
  <pre><code>public function theClass() {
      this.poster = new Loader();
      this.poster.contentLoaderInfo.addEventListener(Event.INIT, this.imageLoaded);
      this.poster.contentLoaderInfo.addEventListener(Event.COMPLETE, this.imageLoaded);
      Stage.addChild(this.poster);
      this.poster.load(new URLRequest('http://example.com/image.jpg'));
  }
  
  private function imageLoaded(event:Event):void {
      trace('image is loaded');
      this.poster.width = 320;
      this.poster.height = 240;
  }
  </code></pre>