beginBitmapFill和drawpath
import flash.display.Sprite;
import flash.filters.DropShadowFilter
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Shape;
import flash.display.Shader;
import flash.display.BitmapData;
import flash.display.Bitmap;
var circle:Sprite = new Sprite();
circle.graphics.beginFill(0xAA0022);
circle.graphics.drawCircle(40, 40, 40);
addChild(circle);
trace(circle.cacheAsBitmap); // false
var filter:DropShadowFilter = new DropShadowFilter();
circle.filters = [filter];
trace(circle.cacheAsBitmap); // true
var t:TextField=new TextField();
t.text="WOCKSODFJ:L";
t.setTextFormat(tf());
function tf():TextFormat{
var t:TextFormat=new TextFormat();
t.font="黑体";
t.size=20;
return t;
}
this.addChild(t);
t.cacheAsBitmap=true;
trace(t.mouseEnabled);
var bd:BitmapData=new BitmapData(400,40,true,0x00);//必须第三个参数为true,且第四个参数存在
bd.draw(t);
var sp:Sprite=new Sprite();
sp.graphics.beginBitmapFill(bd);
this.addChild(sp);
sp.x=49;
var bt:Bitmap=new Bitmap(bd);
this.addChild(bt);
bt.y=30;
sp.buttonMode=true;
//t.buttonMode=true;//此处有错误
import flash.display.Shape;
import flash.display.Sprite;
var i:Number;
var commands:Vector.<int > = new Vector.<int > (5,true);
for (i=0; i<5; i++)
{
if (i != 0)
{
commands[i] = 2;
}
else
{
commands[i] = 1;
}
}
var coord:Vector.<Number > = new Vector.<Number > (10,true);
var arr:Array = new Array(66,10,23,127,122,50,10,49,109,127);
//此处可以使用
//var coord:Vector.<Number>=new <Number>//来替代(66,10,23,127,122,50,10,49,109,127);
for (i=0; i<5; i++)
{
trace(i,arr[2*i]);
coord[2 * i] = arr[2 * i];
coord[2 * i + 1] = arr[2 * i + 1];
}
var sp:Sprite=new Sprite();//
//sp.graphics.lineStyle(2,0xff0000,1);
sp.graphics.beginFill(0x00ff00);
sp.graphics.drawPath(commands,coord,GraphicsPathWinding.NON_ZERO);
this.addChild(sp);
sp.x = 100;
sp.y = 100;