Actionscript 3 AS3-如何';切口';一段有过滤器的精灵?
我使用“drawPath”在精灵上绘制 然后,我使用以下方法对此精灵应用过滤器:Actionscript 3 AS3-如何';切口';一段有过滤器的精灵?,actionscript-3,flash,filter,Actionscript 3,Flash,Filter,我使用“drawPath”在精灵上绘制 然后,我使用以下方法对此精灵应用过滤器: var myBlur:BlurFilter = new BlurFilter(); myBlur.blurX = 10; myBlur.blurY = 10; _alphaMask.filters = [myBlur]; 然后,我需要“剪切”出一部分雪碧,并将其用作另一个雪碧上的遮罩 问题是-当我切割雪碧时-我需要切割的“边缘”不要模糊 但是“模糊过滤器”应用于“剪切”精灵,因此边缘模糊 以下是: 我想到了一种
var myBlur:BlurFilter = new BlurFilter();
myBlur.blurX = 10;
myBlur.blurY = 10;
_alphaMask.filters = [myBlur];
然后,我需要“剪切”出一部分雪碧,并将其用作另一个雪碧上的遮罩
问题是-当我切割雪碧时-我需要切割的“边缘”不要模糊
但是“模糊过滤器”应用于“剪切”精灵,因此边缘模糊
以下是:
我想到了一种解决方法,它有两个问题:
使用过滤器将位图数据从精灵绘制到新精灵,
然后在新精灵上使用“scrollRect”
这种方法有两个问题:
private var _alphaMask:Sprite;
private createMask():void
{
_alphaMask = new Sprite();
_alphaMask.visible = true;
// Clear the mask
_alphaMask.graphics.clear();
// Create the mask vertices (the 'drawPath' coordinates)
var maskPoints:Vector.<Number> = new Vector.<Number>(5);
maskPoints.push(100); maskPoints.push(100);
maskPoints.push(200); maskPoints.push(200);
maskPoints.push(230); maskPoints.push(310);
maskPoints.push(140); maskPoints.push(170);
maskPoints.push(130); maskPoints.push(190);
// Create the 'drawPath' commands
var commands:Vector.<int> = new Vector.<int>(commandLen);
commands.push(1);
commands.push(2);
commands.push(2);
commands.push(2);
commands.push(2);
// Draw the vertices on the mask
_alphaMask.graphics.beginFill(0x0000FF);
_alphaMask.graphics.drawPath(commands, clonedMaskPoints);
_alphaMask.graphics.endFill();
// Add the Blur filter to the mask
var myBlur:BlurFilter = new BlurFilter();
myBlur.blurX = myBlur.blurY = 10;
_alphaMask.filters = [myBlur];
// Now I need to 'Cut Out' a section of the mask (and use it for something else...)
// This section cuts out the part of the mask I need, but it 'reapplies' the blur filter on the entire cut mask
var scrollRect_x:Number = 100;
var scrollRect_y:Number = 100;
var scrollRect_width:Number = 300;
var scrollRect_height:Number = 200
_alphaMask.scrollRect = new Rectangle(scrollRect_x, scrollRect_y, scrollRect_width, scrollRect_height);
}
您已经试图通过复制位图数据来实现这一点,因此我不确定您为什么希望解决方案不这样做。发布你的代码,与快速编写所有新代码相比,向你展示你可以更改的内容会更容易(因此回答问题的人花费的时间更少)。那么这个代码的结果是什么?你说你不能让它工作,但它有任何作用吗?字母面具是空的。没有显示任何内容。如果你只是从alphaBitmapData创建一个位图并将其添加到舞台上,你会看到什么?我只想将一块遮罩“切片”到一个新的Sprite对象上。如何做到这一点?是否需要将其复制到位图对象,然后使用此位图对象创建新的精灵对象?或者我可以直接从我的“精灵”切片到一个新的“精灵”吗?
var alphaBitmapData:BitmapData = new BitmapData(_alphaMask.width, _alphaMask.height);
alphaBitmapData.draw(_alphaMask);
_alphaMask.graphics.clear();
_alphaMask.graphics.beginBitmapFill(alphaBitmapData);
_alphaMask.graphics.endFill();