Skip to content

Instantly share code, notes, and snippets.

@peterblazejewicz
Created May 16, 2011 22:09
Show Gist options
  • Select an option

  • Save peterblazejewicz/975491 to your computer and use it in GitHub Desktop.

Select an option

Save peterblazejewicz/975491 to your computer and use it in GitHub Desktop.
center application NativeWindow on screen with semi-transparent background and content centered on screen
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="800" height="600"
backgroundAlpha="0.90" backgroundColor="#000000"
initialize="visible = false"
creationComplete="setupStage();" >
<!-- -->
<fx:Script>
<![CDATA[
// setup stage align and maximize window
private function setupStage():void
{
if(stage)
{
stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;
stage.align = "";
}
this.nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZE, finishSetup);
this.nativeWindow.maximize();
};
// when window is maximized show window on screen to avoid content flickering
private function finishSetup(resizeEvent:NativeWindowBoundsEvent):void
{
this.nativeWindow.removeEventListener(NativeWindowBoundsEvent.RESIZE, finishSetup);
this.visible = true;
}
]]>
</fx:Script>
<s:Panel width="800" height="600" horizontalCenter="0" verticalCenter="0">
<s:controlBarContent/>
</s:Panel>
</s:WindowedApplication>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment