Adding an asset to the display list : URLRequest « Network « Flash / Flex / ActionScript






Adding an asset to the display list

 

package {
  import flash.display.*;
  import flash.net.URLRequest;
  import flash.events.*;

  public class Main extends Sprite {
    private var loader:Loader;

    public function Main() {
      loader = new Loader();
      loader.contentLoaderInfo.addEventListener(Event.INIT, initListener);
      var urlRequest:URLRequest = new URLRequest("sunset.jpg");
      loader.load(urlRequest);
    }

    private function initListener (e:Event):void {
      addChild(loader.content);  // Add Bitmap object to SunsetViewer
    }
  }
}

        








Related examples in the same category

1.Loading XML Data from External Sources
2.Add URLrequest to Loader
3.Loading XML Data: Event.COMPLETE listener
4.Loading a bitmap at runtime
5.Formatting text with an externally loaded style sheet
6.Starting the load operation
7.Use FileReference to download file from a URL