簡體   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