ボタンのセットをクリックして、シーン上のいくつかのオブジェクトの色を変更する必要がある Adobe Flash/ActionScript 3 のミニアプリに取り組んでいます。同じオブジェクトに対して、(画像を使用して) いくつかのパターンを設定する必要があります。
色の変更はできますが、画像を背景にする方法がわかりません。
どうすればそれができますか?
ありがとうございました!
ボタンのセットをクリックして、シーン上のいくつかのオブジェクトの色を変更する必要がある Adobe Flash/ActionScript 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);