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 回答