Check if sprite is clicked

Hello, I am trying to create a custom button by creating a sprite and adding a eventlistener to check if its clicked but when I run my program it gives me these errors:
src/Main.hx:26: characters 39-44 : Void -> Void should be Dynamic -> Void src/Main.hx:26: characters 39-44 : For function argument 'listener'

When I remove the listener the errors are gone

My main class:


import openfl.display.Sprite;
import openfl.display.SimpleButton;

class Main extends Sprite {

private var button:SimpleButton;
private var s:Spritetest;

public function new () {
	super ();

	this.mouseChildren = false;
	this.buttonMode = true;


public function init() {
	fillBackGround(0xff00ff, 640, 960);
	s = new Spritetest();
	s.addEventListener(MouseEvent.CLICK, click);


public function fillBackGround(color:Int, w:Int, h:Int) {;, 0, w, h);;

public function click() {


my button class


import openfl.display.Sprite;

class Spritetest extends Sprite {

public function new() {
	super();; , 20, 40, 40);;


Sorry for bad english

You should add event parameter to listener:

Also noting there is a bug right now ( where some browsers crash from a missing function when clicking on a sprite. You should be okay testing in Chrome for now. In my experience Bitmaps work correctly, though.