[osflash] haxe: bitmapdata on the fly example, anyone?

Mark Winterhalder mark13 at gmail.com
Wed Aug 22 17:12:19 PDT 2007


So, any chance we'll see Lemmings in haXe? :)

HTH,
Mark

// haxe -swf-header 320:240:31 -swf-version 9 -swf test.swf -main Main.hx

import flash.display.Bitmap;
import flash.display.BitmapData;

class Main {
	static var instance : Main;
	public static function main () : Void {
		instance = new Main();
	}
	
	function new () {
		var img = new Image( 100, 100 );
		flash.Lib.current.addChild( img );
		img.drawRectangle( 0, 0, 100, 100, 0xff0033cc );
		img.drawRectangle( 20, 20, 60, 60, 0xffff33cc );
	}
}

class Image extends Bitmap {
	var data : BitmapData;
	
	public function new ( width : Int, height : Int ) {
		data = new BitmapData( width, height );
		super( data );
	}
	
	public function drawRectangle( x : Int, y : Int, width : Int, height
: Int, ARGBcolor : UInt ) : Void {
		for( py in 0...width ) {
			for( px in 0...height ) {
				data.setPixel32( x + px, y + py, ARGBcolor );
			}
		}
	}
}



More information about the osflash mailing list