在Flash 9之前,含Flash 9,Flash无法实现本地图片预览的功能。Flash 10添加了FileReference.load方法,使得本地图片预览成了可能。使用流程:
FileReference.browse(),FileReference.load(),以及Loader.loadBytes(FileReference.data)
function onComplete (event:Event):void {
loader.loadBytes (file.data);
loader.contentLoaderInfo.addEventListener (Event.COMPLETE,onComplete2);
}
var bitmap:Bitmap;
function onComplete2 (event:Event):void {
/*1. if (bitmap != null)
{
removeChild (bitmap);
}
loader.width=stage.stageWidth;
loader.height=stage.stageHeight;
var container:Sprite=new Sprite();
container.addChild(loader);
var bmpData:BitmapData=new BitmapData(container.width,container.height);
bmpData.draw(container);
bitmap=new Bitmap(bmpData);
addChildAt(bitmap,0)*/
if (bitmap != null)
{
removeChild (bitmap);
}
bitmap = event.target.content as Bitmap;
bitmap.width = stage.stageWidth;
bitmap.height = stage.stageHeight;
addChildAt (bitmap,0);
}
其中liulan是一个按钮,fileName是一个动态文本
参考网上的来做的~