■ ビットマップイメージの特定の領域を塗りつぶすには
//メインタイムラインのフレームアクション
import
flash.display.BitmapData;
import
flash.geom.Rectangle;
this._bmd = new BitmapData(70,
70, false, 0xFFFF66);
this._mc = this.createEmptyMovieClip("bm_mc",
this.getNextHighestDepth());
this._mc._x = 125;
this._mc._y = 85;
this._mc.attachBitmap(this._bmd,
this.getNextHighestDepth());
_btn.onPress = function()
{
var _rect = new Rectangle(0,
0, 20, 20);
var col1_num = 0xFF6666;
_bmd.fillRect(_rect,
col1_num);
_rect.offset(50,0);
_bmd.fillRect(_rect,
col1_num);
_rect.offset(0,50);
_bmd.fillRect(_rect,
col1_num);
_rect.offset(-50,0);
_bmd.fillRect(_rect,
col1_num);
_bmd.fillRect(new Rectangle(20,
20, 30, 30), 0xFF9966);
};
※.このサンプルはActionScript2.0でパブリッシュする必要があります。
--------
サンプル2
//メインタイムラインのフレームアクション
import
flash.display.BitmapData;
this._bitmap = BitmapData.loadBitmap("car");
this._mc = this.createEmptyMovieClip("bm_mc",100);
_mc._x = 65;
_mc._y = 80;
this._mc.attachBitmap(this._bitmap,
10);
this._btn.onRelease
= function(){
_bitmap.floodFill(90,45,0xFF0099);
};
※.このサンプルはActionScript2.0でパブリッシュする必要があります。
--------
サンプル3
//メインタイムラインのフレームアクション
import
flash.display.BitmapData;
import flash.geom.Rectangle;
this._bmd = new BitmapData(280,
135, false, 0xCCCCCC);
this._mc = this.createEmptyMovieClip("bm_mc",
this.getNextHighestDepth());
this._mc._x = 20;
this._mc._y = 50;
this._mc.attachBitmap(this._bmd,
this.getNextHighestDepth());
this.xRandomPix();
this._btn.onRelease
= function(){
_bmd.fillRect(_bmd.getColorBoundsRect(0xFFFFFF,
0xFF0000, true),0x0066FF);
};
function xRandomPix(){
for(var i = 0; i < 10;i++){
var theX = Math.floor(Math.random()
* (this._bmd.width
- 40)) + 20;
var theY = Math.floor(Math.random()
* (this._bmd.height
- 20)) + 10;
this._bmd.fillRect(new
Rectangle(theX,theY,2,2),0xFF0000);
}
}
※.このサンプルはActionScript2.0でパブリッシュする必要があります。

