BitmapData cannot draw bitmap in minus coord

by akisute
♥0 | Line 34 | Modified 2010-03-15 17:09:53 | MIT License
play

ActionScript3 source code

/**
 * Copyright akisute ( http://wonderfl.net/user/akisute )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/nloC
 */

package {
    import flash.display.*;
    import flash.geom.*;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            var sprite:Sprite = new Sprite();
            sprite.graphics.beginFill(0x0000FF, 1);
            sprite.graphics.drawCircle(00,00,10);
            sprite.graphics.endFill();
            sprite.graphics.beginFill(0xFF0000, 1);
            sprite.graphics.drawCircle(0,0,1);
            sprite.graphics.endFill();
            //sprite.x = this.stage.stageWidth / 2;
            //sprite.y = this.stage.stageHeight / 2;
            //this.addChild(sprite);
            
            var container:Sprite = new Sprite();
            sprite.x = 10;
            sprite.y = 10;
            container.addChild(sprite);
            container.x = this.stage.stageWidth / 2;
            container.y = this.stage.stageHeight / 2;
            this.addChild(container);
            
            var bitmapData:BitmapData = new BitmapData(20, 20, true, 0x33333333);
            
            
 			var matrix:Matrix = new Matrix();
			var color:ColorTransform = new ColorTransform(1, 1, 1, 1, 0, 0, 0, 0);
			var rect:Rectangle = new Rectangle(0,
											  0,
											  100,
											  100);
			//Only a quater pie is drawn (since rest of bitmaps data are in minus coordinate)
            //bitmapData.draw(sprite, matrix, color, "normal", rect, true);
            //Works fine because all data are in plus coordinate
            bitmapData.draw(container, matrix, color, "normal", rect, true);
            var bitmap:Bitmap = new Bitmap(bitmapData);
            bitmap.x = this.stage.stageWidth / 2;
            bitmap.y = this.stage.stageHeight / 2 + 40;
            this.addChild(bitmap);
        }
    }
}