Skills
The fill game before Flash8 is usually to separate the colored objects into several small movieclip, and then fill the color separately.
Using Bitmapdata.floodfill to fill the color of the bitmap objects to achieve the region fill color, it seems more convenient, as long as the line to import into the flash, into the bitmapdata can fill color. Here is an example
Effect Demo
Click here to download the source file
Import Flash.display.BitmapData;
var colornumber:number=15; Number of color blocks
var Nowcolor:number; Record current color
var shownowcolor:color=new Color (This.attachmovie ("block", "SHOWNOWCOLORMC", 100,{_x:460,_y:330,_width:50,_height : 50})); Generate a color block to display the current color
for (Var i:number=0;i<colornumber;i++) {//Generate control color block
This.attachmovie ("Block", "Block" +i,i+10,{_x: (i*30+10), _y:350});
var tmpmc:movieclip=eval ("block" +i);
var tmpcolormc:color=new Color (TMPMC);
var tmpcolor:number=random (0XFFFFFF); Random Color
Tmpmc.thiscolor=tmpcolor;
Tmpcolormc.setrgb (Tmpcolor);
Shownowcolor.setrgb (Tmpcolor);
Nowcolor=tmpcolor;
Tmpmc.onrelease=function () {
Nowcolor=this.thiscolor;
Shownowcolor.setrgb (Nowcolor);
}
}
var mybitmapdata:bitmapdata = Bitmapdata.loadbitmap ("Fillpic"); Create a Bitmap object
var mc:movieclip = This.createemptymovieclip ("MC", 1);
Mc.attachbitmap (mybitmapdata,2); Load Bitmap objects
Mc.onrelease=function () {//click to set Color
Mybitmapdata.floodfill (This._xmouse,this._ymouse, Nowcolor); Fill color for current position (contiguous area of the same color, here is white)
FloodFill performs a dumping fill on the image, starting with the (x, y) coordinates to fill a particular color.
}
By extending the instance, you can make the following effect