0

我已将图像资源 (Background.jpg) 导入到我的 Flash CS5 库中,并将其作为基类型为 BitmapData 的类 Bitmap 导出到 ActionScript。

以下代码返回以下错误:

backgroundTexture = new Shape();
backgroundTexture.graphics.beginBitmapFill(Background);
backgroundTexture.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
backgroundTexture.graphics.endFill();

1067:将 Class 类型的值隐式强制转换为不相关的类型 flash.display:BitmapData。

在此处输入图像描述

那么错误是什么?

4

2 回答 2

1

I have more experience with Flex than Flash, so I don't know the UI details, but I believe what you want is:

var background:BitmapAsset = new Background() as BitmapAsset;
backgroundTexture.graphics.beginBitmapFill(background.bitmapData);

This is assuming that your UI generates the following ActionScript or its equivalent:

[Embed(source="Background.jpg")]
public var Background:Class;

See:

于 2011-03-14T17:56:39.533 回答
1

您只需要一个BackgroundBitmapData 对象的实例:

backgroundTexture.graphics.beginBitmapFill(new Background());

Background是对类的引用。new Background()创建类的一个实例。

于 2011-03-14T18:10:34.810 回答