如何在 AS3 中制作面具

How to make a Mask in AS3

我有一个 duvifa 是:

我想知道是否可以按照下面的方式在影片剪辑中制作遮罩:

如果这个图像是游戏的开始。

当用户点击屏幕时,会创建一种奶油,但不会像他那样铺满整个舞台,而是以我的方式。

如下:

也想知道我是否能得到表格中填写内容的百分比,看看用户是否至少填写了 40%。

谢谢你

这是一个使用 flashPro 的简单示例,假设您将形状图形作为导入 .png 库对象,并导出了 MC 的动作脚本 class。

import flash.display.Shape;
import flash.events.Event;
import flash.display.BlendMode;

var mc:MC = new MC(); //the background image
addChild(mc);

var drawing:Shape = new Shape();  //drawing foreground
addChild(drawing);

var mcMask:MC = new MC(); //mask version of background image
addChild(mcMask);

var outerMask:Shape = new Shape(); //this object masks the areas outside the bounds of mcMask object
outerMask.graphics.beginFill(0);
outerMask.graphics.drawRect(0,0,mcMask.width,mcMask.height);
outerMask.graphics.endFill();
addChild(outerMask);

drawing.mask = outerMask; //the mask to the shape whose dimensions equal the image mask

mcMask.blendMode = BlendMode.ALPHA; //this tells the mask graphic to make things underneath it use the same alpha data as this image.  This works will with PNG masks.
this.blendMode = BlendMode.LAYER; //the parent needs to have a blend mode of LAYER for it to work properly

stage.addEventListener(MouseEvent.MOUSE_MOVE,draw);

function draw(e:Event):void {
    trace("draw");
    drawing.graphics.beginFill(0x0000FF);
    drawing.graphics.drawCircle(mouseX,mouseY,10);
    drawing.graphics.endFill();
}