Skip to content

Instantly share code, notes, and snippets.

@wwwins
Created March 23, 2012 07:15
Show Gist options
  • Save wwwins/2167889 to your computer and use it in GitHub Desktop.
Save wwwins/2167889 to your computer and use it in GitHub Desktop.
uploadmanager
private var uploadmanager:UploadManager = UploadManager.Instance;
// init
initUploaderManager();
private function initUploaderManager():void
{
// init uploadmanager
// set file filter
uploadmanager.ApplyFileFilters([new FileFilter("Images (*.jpg, *.jpeg, *.JPG, *.JPEG, *.png, *.PNG)", "*.jpg;*.jpeg;*.JPG;*.JPEG;*.png;*.PNG")]);
uploadmanager.onFileLoaded.add(myPhotoLoaded);
}
private function myPhotoLoaded(__loader:Loader):void
{
while(pic_loader.numChildren){
pic_loader.removeChildAt(0);
}
pic_loader.addChild(__loader);
// fits a DisplayObject into a rectangular area
var area:Rectangle = new Rectangle( 0, 0, 125, 125 );
DisplayUtils.fitIntoRect( __loader, area, true, Alignment.MIDDLE );
Bitmap(__loader.content).smoothing = true;
}
// set mouse click
btn_browse.addEventListener(MouseEvent.CLICK, function(e:MouseEvent){uploadmanager.Browse();});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment