我正在从 Flash 中的图像构建一个立方体。加载器加载图像的精灵图:
+----++----++----++----++----++----+
|frnt||rght||back||left||top ||bot |
| || || || || || |
+----++----++----++----++----++----+
我得到的错误是:
错误 #2005:参数 0 的类型不正确。应该是类型 BitmapData。
在线front.draw(src, null, null, null, clip);
(通过注释掉代码并且没有收到错误来确认)。但我不确定为什么。我定义 src
为BitmapData
, 和 atrace
的src
产生[object BitmapData]
。
private function loaderCompleteListener(e:Event):void
{
log('Complete');
var front:BitmapData,
right:BitmapData,
back:BitmapData,
left:BitmapData,
top:BitmapData,
bottom:BitmapData,
srcData:Bitmap,
src:BitmapData,
clip:Rectangle;
try
{
srcData = this._imageLoader.content as Bitmap;
src = srcData.bitmapData;
front = new BitmapData(src.height, src.height, false, 0);
right = new BitmapData(src.height, src.height, false, 0);
back = new BitmapData(src.height, src.height, false, 0);
left = new BitmapData(src.height, src.height, false, 0);
top = new BitmapData(src.height, src.height, false, 0);
bottom = new BitmapData(src.height, src.height, false, 0);
clip = new Rectangle(0, 0, src.height, src.height);
//This is the line that causes the error
front.draw(src, null, null, null, clip); //<----
clip.x += src.height;
right.draw(src, null, null, null, clip);
clip.x += src.height;
back.draw(src, null, null, null, clip);
clip.x += src.height;
left.draw(src, null, null, null, clip);
clip.x += src.height;
top.draw(src, null, null, null, clip);
clip.x += src.height;
bottom.draw(src, null, null, null, clip);
}
catch ( e:Error )
{
log(e.message);
}
}
我错过了什么?
编辑添加:
一种考虑可能是图像大小。我正在加载 1866×11196 的图像。我明天会测试,看看是否可以使用较小的图像。可能只是 Flash 无法处理超过一定大小的图像。