Terminal Compilation Define Vars

Hi,

I’m a noob.

I’m used to mxmlc compiling and I’m interested moving over to OpenFl / Haxe. I’m struggling to pass variables during compilation. Previously with mxml I could do something like this:

mxmlc -title MyProject -default-size 1080 1920 -default-frame-rate=30 -default-background-color 0x1c1c1c -swf-version=12 -target-player=10.3 -debug=true -static-link-runtime-shared-libraries=true -o=Rush.swf -use-network=false -define=SWFHEIGHT::swfHeight,1920 -define=SWFWIDTH::swfWidth,1080 -define=XMLPATH::xmlPth,’’ src/MyProject.as

The advantage being, the ability to compile a bunch of SWFs with different sizes and unique variables sequentially.

Question One

In my OpenFl .hxproject I’ve got containing width, height, bg color etc. can I overide project variables and pass values during compilation directly the the SWF?

Question Two

I’m able to use conditions like this:

openfl test flash -Dnamevar=“patrick”

And use it like so, in my code.
#if (namevar==“ben”)
txt.text = “HELLO BEN”;
#elseif (namevar==“patrick”)
txt.text = “HELLO PATRICK”;
#end

However I’m struggling to do this:
txt.text = "HELLO "+ namevar;

I’m sure the answers to both these questions are easy enough but I’m struggling. Thanks in advance, any tips / links / advise would be so welcome.

Thanks for your time.

To change the window size:

lime test flash --window-width=100 --window-height=100

This is equivalent to <window width="100" height="100" /> in project.xml. Note that the .hxproj file you mentioned is only used by FlashDevelop, Lime doesn’t care about it.

lime help build lists all “Project Overrides” that exist:

 Project Overrides:

  --app-option=value -- Override a project <app/> setting
  --meta-option=value -- Override a project <meta/> setting
  --window-option=value -- Override a project <window/> setting
  --dependency=value -- Add an additional <dependency/> value
  --haxedef=value -- Add an additional <haxedef/> value
  --haxeflag=value -- Add an additional <haxeflag/> value
  --haxelib=value -- Add an additional <haxelib/> value
  --haxelib-name=value -- Override the path to a haxelib
  --source=value -- Add an additional <source/> value
  --certificate-option=value -- Override a project <certificate/> setting

To retrieve the value of a define, you can use haxe.macro.Compiler.getDefine().

txt.text = "HELLO "+ Compiler.getDefine("namevar");
1 Like

That is awesome. Thank you so much. I think I can do everything I need.
The only niggle I have is how to compile an oversized SWF so that the Flash player window scales to fit the monitor. 1920x1080 for example, goes off my screen, in HTML5 it’s scaled to fit the browser, but in the flash player I only get the top half of the SWF on my monitor.

Is there a way to launch the standalone Flash Player with a scale? I think it usually always does a 1:1 of the stage width/height (though obviously you could scale within your content for a logical scale that’s distinct from the stage width/height :slight_smile: )

Thanks for this.

Apologies if this is getting off topic, feel free to move it under a more appropriate heading.

When I generate a 1920x1080 SWF using Flash / Animate / MXMLC and launch the SWF on my desktop the Flash Player and the content automatically scales the down to the height of the desktop and the width reduces correspondingly, so I see all the content, reduced 1:1.

This does not appear to be the case with OpenFl. When I launch a SWF generated using OpenFl, the height of the player is reduced but the content remains at 1920x1080 with an overflow, so I only see the top of the creative. You are correct in that I can scale down the content using AS3, so that it is all visible 1:1, but the Flash Player doesn’t scale with the content, the height changes, forced down by the monitor size, but the width remains at 1080. So I have a bleed.

Here’s the terminal command I’m using:
openfl test flash --app-file=myApp --app-swfVersion=12 --window-width=1080 --window-height=1920 --window-background=0xFF0000 --window-fps=30

I attach an image:

With AS3 ‘fix’:
var swfStage = this.stage;
swfStage.scaleMode = StageScaleMode.SHOW_ALL;
swfStage.align = StageAlign.TOP_LEFT;

Hope you can fix. While this scaling issue won’t effect anything displaying at 100% I have a client who checks SWFs by launching them as above and I don’t really want to change their workflow, even though I may be changing mine.

Thanks again for your help.

We default stage.scaleMode to NO_SCALE so perhaps setting it manually on the Flash target would help?

Better support for scale modes is TODO on non-Flash targets