       var id:Number = nextId++;
 
       var loader:Loader = new Loader();
-      imageMap[id] = loader;
 
       loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadSuccess);
       loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);

      var urlRequest:URLRequest = new URLRequest(url);
      loader.load(urlRequest, loaderContext);

      return id;

      function loadSuccess(e:Event):void {


        var image:Bitmap = Bitmap(loader.content);

        // Get the image dimensions.
        var imageWidth:Number = image.bitmapData.width;
        var imageHeight:Number = image.bitmapData.height;

        // Convert relative offset and size to absolute values.
        x *= imageWidth;
        y *= imageHeight;
        width *= imageWidth;
        height *= imageHeight;

        // Crop the image if required.
        var bitmapData:BitmapData;
        if (x !== 0 || y !== 0 || width !== imageWidth || height !== imageHeight) {
          bitmapData = new BitmapData(width, height);
          bitmapData.copyPixels(image.bitmapData,
            new Rectangle(x, y, width, height), new Point(0,0));
        } else {
          bitmapData = image.bitmapData;
        }

        imageMap[id] = bitmapData;
        ExternalInterface.call(imageLoadedCallback, false, id);
      }

