[RESOLVED]What is the trick to make an app fit all screen size?

Ok, then I guess you can try it AfroNinja’s way:

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

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

private function onResize(e:Event):Void {
    var stageScaleX:Float = stage.stageWidth / NOMINAL_WIDTH;
    var stageScaleY:Float = stage.stageHeight / NOMINAL_HEIGHT;
    
    var stageScale:Float = Math.min(stageScaleX, stageScaleY);
    
    Lib.current.x = 0;
    Lib.current.y = 0;
    Lib.current.scaleX = stageScale;
    Lib.current.scaleY = stageScale;
    
    if(stageScaleX > stageScaleY) {
        Lib.current.x = (stage.stageWidth - NOMINAL_WIDTH * stageScale) / 2;
    } else {
        Lib.current.y = (stage.stageHeight - NOMINAL_HEIGHT * stageScale) / 2;
    }
}

I should note that I’m testing in OpenFL 2.2.8, not OpenFL 3.

4 Likes