【问题标题】:ActionScript - BeginBitmapFill With BitmapData Library Asset?ActionScript - BeginBitmapFill 与 BitmapData 库资产?
【发布时间】:2023-04-01 21:35:01
【问题描述】:

我已将图像资源 (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: 对值的隐式强制 type 归类为不相关的类型 flash.display:BitmapData.

那么错误是什么?

【问题讨论】:

    标签: actionscript-3 flash bitmap assets


    【解决方案1】:

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

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

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

    【讨论】:

    • 哇,我不敢相信我没有意识到……多么尴尬。谢谢zzzBov。
    • @TheDarkIn1978,这发生在我们最好的人身上。
    【解决方案2】:

    我在 Flex 方面的经验比 Flash 多,所以我不知道 UI 细节,但我相信您想要的是:

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

    这是假设您的 UI 生成以下 ActionScript 或其等效项:

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

    见:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-09
      • 1970-01-01
      • 2011-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-03
      相关资源
      最近更新 更多