繁体   English   中英

如何在flash / as3中将图像设置为影片剪辑的背景?

[英]How can I set an image as background for a movie clip in flash/as3?

我正在使用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);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM