package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BitmapDataChannel;
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.BlurFilter;
import flash.geom.Point;
import flash.geom.Rectangle;
/**
* ...
* @author lizhi
*/
public class Main extends Sprite
{
private var image:Bitmap;
private var sb:BitmapData;
private var bmd:BitmapData;
private var bmdclone:BitmapData;
public function Main():void
{
[Embed(source = "460.jpg")]var c:Class;
bmd = (new c as Bitmap).bitmapData;
image = new Bitmap();
addChild(image);
var s:Shape = new Shape;
s.graphics.beginFill(0);
s.graphics.drawCircle(50, 50, 30);
s.filters=[new BlurFilter(15,15,3)]
sb = new BitmapData(100, 100, true, 0);
sb.draw(s);
stage.addEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMove);
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
}
private function stage_mouseMove(e:MouseEvent):void
{
bmdclone = new BitmapData(bmd.width, bmd.height, true, 0);
bmdclone.setVector(new Rectangle(mouseX - 50,mouseY - 50,100,100), bmd.getVector(new Rectangle(mouseX - 50,mouseY - 50,100,100)));
bmdclone.copyChannel(sb, sb.rect, new Point(mouseX - 50, mouseY - 50), BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA);
image.bitmapData = bmdclone;
e.updateAfterEvent();
}
}
}
|