flash如何做透明渐变效果?
发布网友
发布时间:2022-04-25 19:00
我来回答
共2个回答
热心网友
时间:2023-10-12 13:35
设2曾
第1层做一贞 放图 实例名起下qwe
第2层做一贞 写AS
如下
import flash.geom.Point;
import flash.geom.Matrix;
import flash.display.BitmapData;
function createRef(p_source:MovieClip) {
var bd:BitmapData = new BitmapData(p_source._width, p_source._height, true, 0);
var mtx:Matrix = new Matrix();
mtx.d = -1;
mtx.ty = bd.height;
bd.draw(p_source, mtx);
var width:Number = bd.width;
var height:Number = bd.height;
mtx = new Matrix();
mtx.createGradientBox(width, height, Math.PI/2, 0, 0);
var shape:MovieClip = createEmptyMovieClip("shape", getNextHighestDepth());
//进行线性填充
shape.beginGradientFill("linear", [0, 0], [60, 0], [0, 255], mtx);
shape.lineTo(width, 0);
shape.lineTo(width, height);
shape.lineTo(0, height);
shape.endFill();
shape._visible = false;
var mask_bd:BitmapData = new BitmapData(width, height, true, 0);
mask_bd.draw(shape);
bd.copyPixels(bd, bd.rectangle, new Point(0, 0), mask_bd, new Point(0, 0), false);
var refMC:MovieClip = createEmptyMovieClip("refMC", getNextHighestDepth());
refMC._x = p_source._x;
refMC._y = p_source._y+p_source._height;
refMC.attachBitmap(bd, 0, "Auto ", true);
}
createRef(qwe);
热心网友
时间:2023-10-12 13:36
填充 出现渐变效果. 自己设置吧.