I'm new to haxe/openfl and am trying to simply put a button on a screen. The code below gives me a white screen, no button or reaction to a screen press via trace. Can someone tell me what I'm doing wrong?
package;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
import flash.Lib;
import openfl.Assets;
import flash.display.Sprite;
class Main extends Sprite {
public function new () {
super ();
var sprite = new Sprite();
var bitmapData = Assets.getBitmapData ("images/button.png");
var bitmap = new Bitmap ( bitmapData );
sprite.addChild( bitmap );
// you may need to draw the hitarea
sprite.graphics.beginFill(0xff,0); //transparent
sprite.graphics.lineStyle( 0,0xff, 0); //transparent
// may need to wait for image to load before using width, height - add
// check if required?
sprite.graphics.drawRect( 0, 0, bitmap.width, bitmap.height );
sprite.graphics.endFill();
sprite.addEventListener( MouseEvent.CLICK, function(e: MouseEvent){
trace('clicked');} );
}
}