Hello,
I’ve got a newbie question here…
I’m not sure I understand the difference between flash.display.Sprite and openfl.display.Sprite. For me, flash.display.Sprite can be only used to target the flash platform as it is specific to flash while openfl.display.Sprite can be used to target anything as it is the purpose of openFl to bring the flash API to any platform.
Is that correct?
Thanks!
For most intents and purposes, they are synonyms. When you compile with OpenFL for any non-Flash target, it defines the following:
<haxeflag name="--remap" value="flash:openfl" />
This causes Haxe to replace “flash” with “openfl” in import statements, meaning that flash.display.Sprite
will become openfl.display.Sprite
. On the Flash target, openfl.display.Sprite
is a typedef pointing to flash.display.Sprite
, so either way, the correct class will be used.
There are a few minor differences:
- If you compile without OpenFL, then only
flash.*
imports will work.
- I don’t know if this came to pass, but I remember Joshua saying that the
openfl.*
classes would be able to provide better documentation and code completion.
1 Like
Thanks you very much! I was very confused to often see flash.* import in openFl examples and tutorials but this explains everything!
They were used in previous versions to differentiate the Flash API from the “extra stuff” in OpenFL. But now it is easier to just import everything under openfl.*