1. 实现方法
在flex3中很容易实现全屏,只设置stage的属性stage.displayState为全屏显示即可,而在spark下也就是在flex4.5中要实现全屏显示就得写一个回调函数,因为stage的属性在舞台加载完之后才能使用,在回调函数中设置stage舞台全屏显示的属性即可。
Ø 写个回调函数creationComplete="callLater(fullScreen)"
Ø 实现全屏方法stage.displayState = StageDisplayState.FULL_SCREEN;
2.源代码
<?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"
backgroundColor="#1E46F2"
creationComplete="callLater(fullScreen)">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
protected function fullScreen():void
{
stage.displayState= StageDisplayState.FULL_SCREEN;
}
protected functionqp_clickHandler(event:MouseEvent):void
{
if(stage.displayState== StageDisplayState.FULL_SCREEN){
stage.displayState= StageDisplayState.NORMAL;
qp.label= "全频";
}else{
stage.displayState= StageDisplayState.FULL_SCREEN;
qp.label="退出全屏";
}
}
]]>
</fx:Script>
<s:Button width="134" height="57" label="退出全屏"horizontalCenter="0"verticalCenter="0" id="qp"click="qp_clickHandler(event)"/>
<s:BorderContainer right="10" bottom="10" width="150" height="50" alpha="0.8"
borderVisible="true"cornerRadius="10" dropShadowVisible="true">
<s:Label color="#0471D6"fontFamily="Courier New" fontSize="31"fontStyle="italic"
fontWeight="bold" horizontalCenter="0" text="fly"verticalCenter="0"/>
</s:BorderContainer>
</s:WindowedApplication>