Not to scale stage width and height on html platform

I want my stage not to scale at all. And center itself. For example, if I have 200px x 200px stage, it should not stage as per the browser screen size. But to retain it’s original dimension.

I tried this solution here, but seems not working for me.


///////////////////////////////////////////////////
Update:
Making width and height to 0 in project.xml does restricts the scaling:

 <window width="0" height="0" if="html5" fps="12" />

But I want it to be centered. How to center the stage?
stage.align = StageAlign.CENTER is not working.

I personnaly put everything in a mainSprite, then you just have to center manually this Sprite on your Stage.

Thanks for your reply. Yes, that can be done. But it will add up work for me at this stage of project. I will need to change references in my code. So wondering if there is some in built way to do this.

How about this?

//Insert your values here:
private static inline var NOMINAL_WIDTH:Int = 200;
private static inline var NOMINAL_HEIGHT:Int = 200;

public function new() {
    super();
    
    //...
    
    #if flash
        stage.scaleMode = StageScaleMode.NO_SCALE;
        stage.align = untyped "";
    #else
        stage.addEventListener(Event.RESIZE, onResize);
        onResize(null);
    #end
}

private function onResize(e:Event):Void {
    Lib.current.x = (stage.stageWidth - NOMINAL_WIDTH) / 2;
    Lib.current.y = (stage.stageHeight - NOMINAL_HEIGHT) / 2;
}

If that works, great! If not, please describe your problem in more detail. What happens when you run it? What do you want to happen?

setting width and height to zero doesn’t restrict the scaling, it turns on autoresize.

What you probably want is
<window width="200" height="200" resizable="false" />

Then you can use html to center the canvas element