The following simple example for catching events does not produce any event on an html5 platform on OSX (after attempting to click on the req rectangle). I have tried the project on both chrome and safari browsers. Am I losing my sanity or did I just forget something trivial?
package;
import openfl.events.Event;
import openfl.events.MouseEvent;
import openfl.display.Sprite;
class Main extends Sprite
{
public function new()
{
super();
addEventListener(Event.ADDED_TO_STAGE, init);
}
public function init(e:Event)
{
removeEventListener(Event.ADDED_TO_STAGE, init);
var s = new Sprite();
s.x = s.y = 0;
s.width = s.height = 500;
s.graphics.beginFill(0xFF0000);
s.graphics.drawRect(0,0,500,500);
s.graphics.endFill();
s.addEventListener(MouseEvent.MOUSE_DOWN, test);
s.addEventListener(MouseEvent.MOUSE_UP, test);
s.addEventListener(MouseEvent.CLICK, test);
stage.addChild(s);
}
public function test(e:MouseEvent)
{
trace(e);
}
}
I checked and init is called (the rectangle is drawn). Even with the addChild instead of stage.addChild, the same problem occurs…no events being fired.
I have a stock setup on my mac, and can’t make any sense of this issue. Can anyone reproduce? Does the example work on your setups for the html5 target?
EDIT: Yesterday, I have updated the libs. Same issue.
EDIT : I asked this because this event fires better in html5 (especialy on mobile) in my tests but anyway this is not the problem here. See my next message.
Just did, I have added: s.addEventListener(MouseEvent.MOUSE_OVER, test); s.addEventListener(MouseEvent.MOUSE_OUT, test);
Same issue, no event whatsoever. Does it work on your own html5 test?
You have already this line to set the width and height.
Maybe you can try to change the width and height with s.width = s.height = 500; (but put this line after s.graphics.endFill();) Is the bug still occurs if you put the buggy line after creating the graphics?