Openfl 4.8.1 : Lib.current.stage.stageWidth or Lib.current.stage.stageHeight not working properly at Preloader iOS Mobile Browser (HTML5)

I’m using openfl 4.8.1 and lime 3.7.4 for html5 games.

Lib.current.stage.stageHeight and Lib.current.stage.stageWidth not working after I rotate the iOS mobile device while in Preloader.hx class at iOS Mobile Browser. Lib.current.stage.stageHeight and Lib.current.stage.stageWidth return same value with before I rotate it.

Lib.current.stage.stageHeight and Lib.current.stage.stageWidth working fine at Preloader android browser and pc browser.

So It’s only work once at iOS when first load preloader only. If I rotate it the mobile device, Lib.current.stage.stageHeight and Lib.current.stage.stageWidth always return same value with before I rotate it.

After Main class loaded Lib.current.stage.stageHeight and Lib.current.stage.stageWidth working fine on iOS browser

I need Lib.current.stage.stageHeight and Lib.current.stage.stageWidth to handle screen rotation on mobile at preloader screen.

Can you tell if stage.window.width and stage.window.height update properly?

I wonder if this is an underlying Lime issue, or somehow we aren’t handling Lime resize until after preloading

Thank you

stage.window.width and stage.window.height have same result like Lib.current.stage.stageHeight and Lib.current.stage.stageWidth return same value.

It appears that the logic depends on the window “resize” event in the browser

I wonder if this event is being dispatched at the correct time, or if we need to handle some additional event

It’s seems Browser.window.addEventListener (“resize”, handleWindowEvent, false);

not triggered at ios mobile browser (Preloader class). Is there any event beside resize? Or we must wait for lime to fix it?

Can you tell if your canvas is being resized as well?

Perhaps we need to listen to the root DOM element (such as the target DIV) rather than the page resizing, so if our target element resizes, we respond that way

Can you tell if your canvas is being resized as well?

How to do it?
Do you mean the screen after rotate? If that so, the screen was not resized after I rotate it because I’m using

	Lib.current.stage.color     = 0x000000;
	Lib.current.stage.align     = StageAlign.TOP;
	Lib.current.stage.quality   = StageQuality.BEST;
	Lib.current.stage.scaleMode = StageScaleMode.SHOW_ALL;	

And I handle the screen size with this function :

private function setupAspectRatio() {
	aspectRatio  = Math.min(Lib.current.stage.stageWidth / Setting.GAME_WIDTH, Lib.current.stage.stageHeight / Setting.GAME_HEIGHT);
	if (aspectRatio != 1) {
		scaleX = aspectRatio;
		scaleY = aspectRatio;			
	}			
}

That’s why I need to know the width and height browser window after rotate it.

Perhaps we need to listen to the root DOM element (such as the target DIV) rather than the page resizing, so if our target element resizes, we respond that way

I don’t know what to do. Should we ask the lime team?

Okay, I think this should fix it:

Previously, a resize occurred only on a window resize. Now it will occur if the parent element is resized, so if you change the CSS on the parent DIV (for example) it will resize. A rotation event should resize a 100% x 100% element, which should now trigger a window resize event :smile:

It’s work now after I update that 2 class

Thank you for your help @singmajesty :slight_smile:

1 Like