Adjusted code to work on haxe3 and openfl/lime.