Skip to content

Instantly share code, notes, and snippets.

@SnugglePilot
Last active December 25, 2015 13:29
Show Gist options
  • Save SnugglePilot/6984043 to your computer and use it in GitHub Desktop.
Save SnugglePilot/6984043 to your computer and use it in GitHub Desktop.
function onStageResize(e:Event) {
// Not pictured: backdrop is a Sprite that has .addChild(new Bitmap()) graphics contained.
// Using Haxe3 + openFL 1.0
if (stage.stageWidth > stage.stageHeight) {
// This always works:
backdrop.rotation = 0;
backdrop.x = 0;
backdrop.y = 0;
backdrop.width = stage.stageWidth;
backdrop.height = stage.stageHeight;
} else {
backdrop.rotation = 0;
// The above line should not be necessary. But without it, the following two lines do not take effect:
backdrop.width = stage.stageHeight;
backdrop.height = stage.stageWidth;
// Probably because the backdrop rotation was triggered on a previous tick.
backdrop.rotation = 90;
// (Handle top left registration point:)
backdrop.x = stage.stageWidth;
backdrop.y = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment