#2015:无效的位图数据

发布于 2024-08-16 15:27:17 字数 475 浏览 4 评论 0原文

在我的类中,如果我像这样创建 bitmapData:

private var tImage:BitmapData;


public function object():void {
        tImage = new BitmapData(30,30,false,0x000000);
}

我收到以下错误:

ArgumentError: Error #2015: Invalid BitmapData.

但如果我在方法内声明变量:

public function object():void {
    var tImage:BitmapData;
    tImage = new BitmapData(30,30,false,0x000000);
}

它工作正常。为什么!?!?!这让我发疯。

谢谢你们!

In my class, if I create bitmapData like this:

private var tImage:BitmapData;


public function object():void {
        tImage = new BitmapData(30,30,false,0x000000);
}

I get the following error:

ArgumentError: Error #2015: Invalid BitmapData.

But if I declare the variable inside the method:

public function object():void {
    var tImage:BitmapData;
    tImage = new BitmapData(30,30,false,0x000000);
}

It works fine. WHY!?!?! It's driving me crazy.

Thanks guys!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

乖乖公主 2024-08-23 15:27:17

我认为这可能是您班级中的其他代码。

以下内容有效,但我没有将函数命名为“object”(因为我猜测这是一个保留字??)

package
{
/**
* ...
* @author your name here
*/
  import flash.display.MovieClip;
  import flash.events.Event;
  import flash.display.Bitmap;

  public class TestBitmap extends MovieClip
  {

    private var tImage:BitmapData;

    public function TestBitmap():void
    {
      if (stage) init();
      else addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init(e:Event = null):void 
    {
            tImage = new BitmapData(30,30,false,0x000000);
    }
  }
}

下面的简化版本也有效:

package
{
/**
* ...
* @author your name here
*/
  import flash.display.MovieClip;
  import flash.events.Event;
  import flash.display.Bitmap;

  public class TestBitmap extends MovieClip
  {

    private var tImage:BitmapData;

    public function TestBitmap():void
    {
     tImage = new BitmapData(30,30,false,0x000000);
    }


  }
}

I think it might be some other code in your class.

The following works, but I didn't name the function "object" (since I'm guessing that's a reserved word??)

package
{
/**
* ...
* @author your name here
*/
  import flash.display.MovieClip;
  import flash.events.Event;
  import flash.display.Bitmap;

  public class TestBitmap extends MovieClip
  {

    private var tImage:BitmapData;

    public function TestBitmap():void
    {
      if (stage) init();
      else addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init(e:Event = null):void 
    {
            tImage = new BitmapData(30,30,false,0x000000);
    }
  }
}

This simplified version below also works too:

package
{
/**
* ...
* @author your name here
*/
  import flash.display.MovieClip;
  import flash.events.Event;
  import flash.display.Bitmap;

  public class TestBitmap extends MovieClip
  {

    private var tImage:BitmapData;

    public function TestBitmap():void
    {
     tImage = new BitmapData(30,30,false,0x000000);
    }


  }
}
稳稳的幸福 2024-08-23 15:27:17

您将 tImage 声明为私有...

private var tImage:BitmapData;


public function object():void {
        tImage = new BitmapData(30,30,false,0x000000);
}

它应该是

var tImage:BitmapData;


public function object():void {
        tImage = new BitmapData(30,30,false,0x000000);
}

Derp

You declared tImage as private...

private var tImage:BitmapData;


public function object():void {
        tImage = new BitmapData(30,30,false,0x000000);
}

Its should be

var tImage:BitmapData;


public function object():void {
        tImage = new BitmapData(30,30,false,0x000000);
}

Derp

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文