I’m sure someone will fill in the technical details in the comments (hint hint, AIR experts), but here’s what I ran into.

I’m building an image upload system, and I’m allowing people to drag & drop images onto the app for upload. When they drop the images, I put all the File objects into an ArrayCollection, and then I rendered previews in a giant TileList driven off that ArrayCollection. Now, I figured that might be a little intensive, but it was taking 5-10 seconds to scroll down one row. I figured that it was just beyond AIR’s capabilities to render these jpg files (they are 2-10MB each) that fast, even off the local file system. So, I switched my TileList to a List, but had the same problem, even though I was just displaying File.name.

When I had that result, I figured there must be something about the flash.filesystem.File object that was causing the problem. So, I created a shadow ArrayCollection that I filled with a custom object, FileLight:

package org.iotashan.file {
  public class FileLight {
    public var name:String;
    public var extension:String;
    public var nativePath:String;
  }
  public function FileLight(name:String,extension:String,nativePath:String) {
    this.name = name;
    this.extension = extension;
    this.nativePath = nativePath;
  }
}

When I drove the TileList off of the ArrayCollection filled with FileLight objects, performance came back to acceptable levels. Feel free to use that code however you want.

Help make me popular:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • Pownce
  • Slashdot
  • StumbleUpon

This entry was posted on Wednesday, April 9th, 2008 at 12:00 am and is filed under Development. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply