stop();
var file:FileReference;
var fileLoader:Loader;
function start()
{
loadImageBtn.addEventListener(MouseEvent.CLICK, showDialog);
}
start();
function showDialog(event:MouseEvent):void
{
file = new FileReference();
var imageFileTypes:FileFilter = new FileFilter("Images (*.jpg, *.png)", "*.jpg;*.png");
file.browse([imageFileTypes]);
file.addEventListener(Event.SELECT, selectFile);
}
function selectFile(e:Event):void
{
file.addEventListener(Event.COMPLETE, loadFile);
file.load();
}
function loadFile(e:Event):void
{
fileLoader = new Loader();
fileLoader.addEventListener(Event.COMPLETE, displayImage);
fileLoader.loadBytes(file.data);
}
function displayImage(e:Event):void
{
addChild(fileLoader);
}