Adapted to OpenFL

Previous implementation caused "Document is missing element map" error after switching from haxe 2 + nme to haxe 3 + openfl.