Conditional compilation with haxedef if=

Why does the following not work?


<haxedef name="WAV" if="android||flash" />
<assets path="Assets/snd" rename="assets/snd" type="audio" include="*.WAV" if="WAV" />
<assets path="Assets/snd" rename="assets/snd" type="audio" include="*.ogg" unless="WAV" />


  public static var snd_COIN: Sound = null;
#if WAV
    snd_COIN = Assets.getSound ("assets/snd/COIN.WAV");
    snd_COIN = Assets.getSound ("assets/snd/COIN.ogg");
  ... ();

When I compile for flash, it says: Warning: Skipping unsupported OGG file “Assets/snd/COIN.ogg” and then [Assets] There is no audio asset with an ID of “assets/snd/COIN.WAV” and then can’t play the sound.
If I add -DWAV to the command line it works fine.

Try <set />

Using -D on the command-line is equivalent to both set and haxedef, perhaps we should consider a change in this behavior in the future

A “set” value affects project parsing, a haxedef is passed to the Haxe compile process :slight_smile:

I need to write conditional statement within project.xml in order to use correct android icon based on a flag value, but below approach doesn’t work in current haxe flixel.

		<icon path="devicon.svg" if="!ADMOBPROD" />
		<icon path="prodicon.svg" if="ADMOBPROD"  />

Hi, not sure you can use “!” here : I think that’s what “unless” is for

<icon path="devicon.svg" unless="ADMOBPROD" />


I also need it work with prodicon.svg as well. I need to pick one of two icons to compile based on a flag.
I wanted to display a different android icon to show if it’s an dev/prod version.

Sorry I only wrote the part that I think needs to be changed, the whole thing should look like

<icon path="devicon.svg" unless="ADMOBPROD" />
<icon path="prodicon.svg" if="ADMOBPROD"  />

didn’t test but should work I think ?

1 Like