2012年3月23日 星期五

fileReference upload manager

久沒用記一下..XD


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();});
view raw gistfile1.as hosted with ❤ by GitHub

沒有留言:

張貼留言