private static var tileDir:String;
public static var tileImage:BitmapData;
pri开发者_运维百科vate static var loader:Loader;
public static var tileReady:EventDispatcher = new EventDispatcher();
public static var tileNum_perRow:Number = 3;
public static var select:selector;
public var tileNum:Number = 0;
public var setBack:Number = 0;
public var tileState:String;
public var tCol:Number;
public var tRow:Number;
private var tWidth:int = 30;
private var tHeight:int = 30;
private var tImage:BitmapData;
private var canvas:Bitmap;
private var p:Point;
private var r:Rectangle;
public function Tile():void
{
var tempImage:BitmapData = tileImage;
r = new Rectangle(0,0,30,30);
p = new Point(0,0);
tImage = new BitmapData(30,30);
tImage.copyPixels(tempImage,r,p);
}
And I get the following error:
ArgumentError: Error #2015: Invalid BitmapData.
It tends to happen when I copy the pixels. I dont know why.
tileImage;
tileImage is valid, I've used the variable in the code below and it works. But above doesnt. Don't know why. Anyone have any clues?
this.graphics.beginBitmapFill(tileImage);
this.graphics.drawRect(60, 0,tWidth ,tHeight );
Nevermind, I figure a better solution
theMatrix.translate(30,0);
this.graphics.beginBitmapFill(tileImage,theMatrix);
//this.graphics.drawRect(0, 0,tWidth ,tHeight );
this.graphics.endFill();
using the theMatrix.translates give you the ability to choose what part of the tile you want, without effecting the position of the sprite
精彩评论