HTML5, lost control of resize event

I’ve just moved from Open FL 3.1 to 3.4 , and appear to have lost control of a number of crucial events when targetting this platform.

my stage rezise listener no longer fires when targetting html (but does on other targets i.e. flash, neko, windows )

Lib.current.stage.addEventListener(Event.RESIZE, resize);

my injected js visibilitychange listener also no longer fires when the “visibilitychange” event occurs.

untyped __js__ ("document.addEventListener(\"visibilitychange\", $bind(this,this.handleVisibilityChange));");

Looking at the generated .js there appears to be a HandleWindowEvent for “resize” , which in turn calls[0].backend.handleResize(); which appears to scale and offset the canvas <div> to resize it.

I’d like to a) reenable my own handling of the resize event, (as i used to in 3.1.0, and still have to on my other targets) , and b) I’d also like to be able to make my canvas use the full viewable browser window when a size event occurs, rather than it being shrunk to a rectangle in the centre of the window. So is there an easy way to override the <div> based scaleing and offsetting that’s been introduced since 3.1 ?

HTML5 uses the target DIV element (or optionally canvas element) to handle it’s resizing based on how you define your window. A default size of 0x0 uses the full HTML element size, while a specific size (like 800x600) automatically scales and adds a letter box to fit the parent DIV.

Either using a different window size value (such as not defining it) or using surrounding HTML that sets your target embed DIV to a size you want, should get what you are looking for?

great, thanks you for the reply ! I understand now, the div was changing the apparent size, so the stage wasn’ actually changing size at all, so the resize event wasn’t occuring - i’ve gone back to an older application.xml, and copied over

<window width="0" vsync="true" height="0" fps ="61" if="html5" />

to the new project.xml , and i’m in control again !

1 Like