forked from: LiquidFx
import com.bit101.components.PushButton;
/**
* Copyright hacker_z0t8xpld ( http://wonderfl.net/user/hacker_z0t8xpld )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/64RS
*/
package
{
import flash.display.Sprite;
import flash.display.Loader;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.FileFilter;
import flash.net.FileReference;
// import com.bit101.components.PushButton;
public class Main extends Sprite
{
private var fileReference:FileReference;
public function Main()
{
fileReference = new FileReference();
fileReference.addEventListener(Event.SELECT, selectHandler);
fileReference.addEventListener(Event.COMPLETE, completeHandler);
stage.addEventListener(MouseEvent.CLICK, onMouseClick);
//var button:PushButton = new PushButton(this, 0, 0, "LOAD", onMouseClick);
}
private function onMouseClick(event:MouseEvent):void
{
var fileFilter:FileFilter = new FileFilter("Images(JPEG, GIF, PNG)", "*.jpg;*.gif;*.png");
fileReference.browse([fileFilter]);
}
private function selectHandler(event:Event):void
{
//trace(event.currentTarget); // [object FileReference]
//trace(event.currentTarget.name); // 選んだファイル名
//trace(fileReference.name) // 選んだファイル名
fileReference.load();
}
private function completeHandler(event:Event):void
{
var loader:Loader = new Loader();
loader.loadBytes(fileReference.data);
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
}
private function initHandler(event:Event):void
{
var loader:Loader = event.currentTarget.loader;
loader.y = 20;
addChild(loader);
}
}
}