Read project properties from code

Is it possible to read window properties from code?
<window width="820" height="640"/>

This will reveal those numbers:
trace(openfl.Lib.application.window.width, openfl.Lib.application.window.height);

or even the good old flash-way:
trace(stage.stageWidth, stage.stageHeight);

That’s not exactly what I want.
stage.stageWidth changes during resize. I just need values from project.xml :slight_smile:

But openfl.Lib.application.window.width should be what you want. :wink:

1 Like

It still returns actual width :frowning:

What do you get if you try this:
trace(openfl.Lib.application.config.windows[0].width, openfl.Lib.application.config.windows[0].height);

Error:(88, 42) openfl.display.Application has no field config

stage.window.context.attributes has some settings but I’m not sure if width and height are there

You could use a define if you need to

<define name="window-width" value="820" />
<define name="window-height" value="640" />
<window width="${window-width}" height="${window-height}" />
var width = haxe.Compiler.getDefine("window-width");
var height = haxe.Compiler.getDefine("window-height");
2 Likes