1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onLoadImage()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.display.*;
private var fileReferenceLoad:FileReference = new FileReference();
private function onLoadImage():void
{
var f:FileFilter = new FileFilter("Images", "*.swf;*.gif;*.png;*.jpeg");
fileReferenceLoad.browse([f]);
fileReferenceLoad.addEventListener(Event.SELECT,onFileSelect);
fileReferenceLoad.addEventListener(Event.COMPLETE,onFileComplete);
}
private function onFileSelect(event:Event):void
{
fileReferenceLoad.load();
}
private function onFileComplete(event:Event):void
{
var byteArray:ByteArray = fileReferenceLoad.data;
var loader:Loader = new Loader();
var loaderContext:LoaderContext = new LoaderContext(false);
loaderContext.allowLoadBytesCodeExecution = true;
loader.loadBytes(byteArray,loaderContext);
addChild(loader);
}
]]>
</mx:Script>
</mx:WindowedApplication> |
Partager