title: AS3 : Load image from xml
body: <p>I try to load images from xml.
  My script is on frame 1.</p>
  
  <pre><code>var fichierXML:URLRequest = new URLRequest("datas.xml");
  
  //Chargement du fichier
  var loader:URLLoader = new URLLoader();
  loader.addEventListener(Event.COMPLETE, onLoaded);
  loader.load(fichierXML);
  
  //Traitement des données
  function onLoaded(e:Event):void
  {
  //Récupération des données du fichier XML
  var xml:XML = new XML(e.target.data); 
  
  //Extraction des données généralistes
  var Name:XMLList = xml.list.name; 
  var pictureProfilOriginal:XMLList = xml.list.pictureProfilOriginal; 
  var pictureProfil:XMLList = xml.list.pictureProfil; 
  var totalView:XMLList = xml.list.totalView; 
  var totalLoves:XMLList = xml.list.totalLoves; 
  
  loadImage(image01, "crop_image_1.jpg");
  }
  
  function loadImage(mc:MovieClip, urlReq:String):void {      
  var loader:Loader = new Loader();
  mc.addChild(loader);
  loader.contentLoaderInfo.addEventListener(Event.COMPLETE, doneLoad);
  // start loading
  loader.load(new URLRequest(urlReq));
  }
  
  function doneLoad(e:Event):void {
  e.target.loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, doneLoad);
  
  // smoothing the bitmap
  var bit:Bitmap = e.target.content;
  if(bit != null)
  bit.smoothing = true;
  }
  </code></pre>
  
  <p>When my clip "image01" is on frame 1, it load my image crop_image_1.jpg, but if my clip "image01" is on frame 2, i have this error :</p>
  
  <pre><code>TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
  at Film_animation_fla::MainTimeline/loadImage()    [Film_animation_fla.MainTimeline::frame1:68]
  at Film_animation_fla::MainTimeline/onLoaded()  [Film_animation_fla.MainTimeline::frame1:62]
  at flash.events::EventDispatcher/dispatchEventFunction()
  at flash.events::EventDispatcher/dispatchEvent()
  at flash.net::URLLoader/onComplete()
  </code></pre>
  
  <p>I begin with actionscript, maybe anyone have an idea to help me.</p>
  
  <p>Thanks</p>