1

ボタンのセットをクリックして、シーン上のいくつかのオブジェクトの色を変更する必要がある Adob​​e Flash/ActionScript 3 のミニアプリに取り組んでいます。同じオブジェクトに対して、(画像を使用して) いくつかのパターンを設定する必要があります。

色の変更はできますが、画像を背景にする方法がわかりません。

どうすればそれができますか?

ありがとうございました!

4

1 に答える 1

3

Graphics画像の描画に使用できます。

// Draw the background
var shape:Shape = new Shape();
shape.graphics.beginBitmapFill(myBitmapData);
shape.drawRect(0, 0, myBitmapData.width, myBitmapData.height);
shape.endFill();

// Reference for later
var background:DisplayObject = shape;

Bitmapを使用して画像を表示することもできます。

// Display the image
var bitmap:Bitmap = new Bitmap(myBitmapData);

// Reference for later
var background:DisplayObject = bitmap;

これで、この背景をオブジェクトに追加できます。

// Add the background at the lowest depth level
myObject.addChildAt(background, 0);
于 2012-08-01T09:09:45.210 に答える