AS3: using beginBitmapFill() with a library object
How can I setup a .beginBitmapFill() with a bitmap loaded into the movie's library? Every example I've found on the internet uses the loader class to load the bitmap externally, but I want to load it from the librar开发者_如何学编程y instead.
I want to turn:
mesh.graphics.beginFill(0xFFFFFF,1);
into
mesh.graphics.beginBitmapFill(..., null, true, false);
and have my shape filled with a tiled 'bitmap.bmp' loaded into the library. The major problem is how I can address the library bitmap inside the fill method.
add the image file to your library and export it to ActionScript as a BitmapData object:
then you can write the graphics code like this:
import flash.display.BitmapData;
import flash.display.Shape;
var mesh:Shape = new Shape();
mesh.graphics.beginBitmapFill(new MeshBitmapData(), null, true, false);
mesh.graphics.drawRect(0, 0, 400, 400);
mesh.graphics.endFill();
mesh.x = mesh.y = 20;
addChild(mesh);
and you will get this:
精彩评论