1 Reply Latest reply on Nov 19, 2007 10:35 AM by Mihai Corlan

    Loading Images

    evsPeart Level 1
      Hi,

      I have this example for loading images but just one at the time, I need to do it but with multiples images and loading in a TileList control or something like that. Here is the code:


      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">

      <mx:VBox height="100%" width="100%"
      paddingTop="5" paddingBottom="5"
      paddingLeft="5" paddingRight="5">

      <mx:Button y="78" label="Load Image" id="btnImage" click="loadImage();" horizontalCenter="0"/>
      <mx:Image id="imgLoader" horizontalCenter="0" verticalCenter="0" creationComplete="initApp();" />

      </mx:VBox>

      <mx:Script>
      <![CDATA[

      import flash.desktop.DragManager;
      import flash.desktop.ClipboardTransferMode;
      import flash.desktop.ClipboardFormats;
      import flash.desktop.DragActions;


      import flash.filesystem.File;

      private var imageFile: File;

      private function loadImage(): void
      {
      var imageFilter:FileFilter = new FileFilter("Images", "*.jpg;*.gif;*.png;*.swf;");
      imageFile = new File();
      imageFile.browseForOpen("Select an image", [imageFilter]);
      imageFile.addEventListener(Event.SELECT, imageSelected);

      }

      private function imageSelected(event:Event):void
      {
      imgLoader.source = imageFile.url;

      }

      private function initApp():void
      {
      addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER,
      dragEnter);
      addEventListener(NativeDragEvent.NATIVE_DRAG_DROP,
      draggedImage);

      }

      private function dragEnter(event:NativeDragEvent):void
      {
      DragManager.acceptDragDrop(this);
      }

      private function draggedImage(event:NativeDragEvent):void
      {
      var files:Array =
      event.clipboard.dataForFormat(ClipboardFormats.FILE_LIST_FORMAT
      ) as Array;
      imgLoader.source = files[0].url;
      }

      ]]>
      </mx:Script>


      </mx:WindowedApplication>

      I need to load the several images in a control of flex and show it to the user, all of them at same time.

      Regards,
      Evs Peart