haxe

What does it mean for `haxe --resource <file>[@name]` to "add" a named resource?


The Haxe manual page for compiler usage shows

-r <file>[@name] (or --resource <file>[@name]) Add a named resource file.

What does it mean for it to "add" a named resource file? Add it to what? Is the @name part optional? How can I access this custom name?


Solution

  • -r / --resource adds resources that are then accessed through haxe.Resource.

    So, if you do --resource test.txt, you'll be able to do Resource.getString("test.txt") to retrieve the contents of the resource.

    Using @name allows to override the resource name - if you do --resource test.txt@X, you would be accessing it using Resource.getString("X") instead.