Pay for Hesitation: capture the screenshot from the stage of Flash Player
Pay for Hesitation
Ideas are Worthless Unless Acted Upon
Pages
Home
Authors
2010年7月15日 星期四
capture the screenshot from the stage of Flash Player
package
{
import com.adobe.images.JPGEncoder; //from as3corelib library
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.net.FileReference;
import flash.utils.ByteArray;
public class TestScreenShot extends Sprite
{
public function TestScreenShot()
{
this.graphics.beginFill(0x33bb00, 0.5);
this.graphics.drawCircle(100, 100, 100);
this.graphics.endFill();
captureScreenShot();
}
public function captureScreenShot():void
{
var bitmapData :BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true);
var bitmap :Bitmap = new Bitmap(bitmapData, "auto", true);
var jpgEncoder :JPGEncoder = new JPGEncoder(90);
bitmapData.draw(this);
var byteData :ByteArray = jpgEncoder.encode(bitmapData);
var file:FileReference = new FileReference();
file.save(byteData, "screenshop.jpg");
trace("taken screenshot");
}
}
}
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言