Hey Bernhard and fellow StageXL contributors,
As of Dart SDK 2.0.0-dev.53.0, dartdevc's (dart2js respectively) default settings will use the Dart 2 type system, which results in StageXL's event engine producing errors at runtime.
Example
Sprite p = new Sprite();
p.graphics.rect(0, 0, 200, 50);
p.graphics.fillColor(Color.Red);
p.addEventListener<MouseEvent>(MouseEvent.MOUSE_DOWN, _onSubmit);
stage.addChild(p);
void _onSubmit(MouseEvent e) {
print("submitted");
}
Result: Type '(MouseEvent) => void' is not a subtype of type '(Event) => void' in strong mode
This listener will work, though:
void _onSubmit(Event e) {
MouseEvent me = e as MouseEvent;
print("test: ${me.localX}");
}
Now, unfortunately, debugging Dart 2 is still hard, so that currently I can only assume that the culprit is either in EventDispatcher's dispatchEvent and dispatchEventRaw, or it's a bug in Dart 2 – because I would think that MouseEvent is a subtype of Event.
Long story short:
- Any of you guys have an explanation?
- Any of you working on migrating StageXL to Dart 2?
-- If not, I guess I'll be able find time to take a first shot at it these days.
Thanks,
Nils