import com.adobe.images.JPGEncoder;
import com.adobe.images.PNGEncoder;
import flash.filesystem.*;
jpg_btn.addEventListener(MouseEvent.CLICK, saveImg);
png_btn.addEventListener(MouseEvent.CLICK, saveImg);
function saveImg(e:MouseEvent):void {
var tname = e.target.name;
var file:File = File.applicationResourceDirec tory;
var bpd:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
var ba:ByteArray;
bpd.draw(root);
if(tname == "jpg_btn"){
var jpg:JPGEncoder = new JPGEncoder(80);
ba = jpg.encode(bpd);
file = file.resolve("test.jpg");
}else if(tname == "png_btn"){
ba = PNGEncoder.encode(bpd);
file = file.resolve("test.png");
}
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.WRITE);
fileStream.writeBytes(ba);
fileStream.close();
}
import com.adobe.images.PNGEncoder;
import flash.filesystem.*;
jpg_btn.addEventListener(MouseEvent.CLICK, saveImg);
png_btn.addEventListener(MouseEvent.CLICK, saveImg);
function saveImg(e:MouseEvent):void {
var tname = e.target.name;
var file:File = File.applicationResourceDirec
var bpd:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
var ba:ByteArray;
bpd.draw(root);
if(tname == "jpg_btn"){
}else if(tname == "png_btn"){
}
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.WRITE);
fileStream.writeBytes(ba);
fileStream.close();
}
<script type="text/javascript" id="wumiiRelatedItems"> </script>