Flash AS3 Mask Layer effect

Source: Internet
Author: User
The code is as follows Copy Code

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 (+, 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,10 0,100));
Bmdclone.copychannel (SB, Sb.rect, New Point (mouseX-50, mouseY-50), Bitmapdatachannel.alpha, Bitmapdatachannel.alpha) ;
Image.bitmapdata = Bmdclone;
E.updateafterevent ();

}

}

}

Effect Address http://game-develop.net/swfs/meinvfilter/

In fact, the principle is very simple is a flash to take the effect of the mega-layer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.