<?xml version="1.0" encoding="utf-8"?>
<s:Application 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="#5C5A5A" width="550" height="338">
<fx:Script>
<![CDATA[
import flash.display.StageDisplayState;
protected function button1_clickHandler(event:MouseEvent):void
{
switch (stage.displayState) {
case StageDisplayState.FULL_SCREEN:
stage.displayState = StageDisplayState.NORMAL;
break;
default:
stage.displayState = StageDisplayState.FULL_SCREEN;
break;
}
id1.text = stage.displayState;
id2.text = stage.height.toString();
}
]]>
</fx:Script>
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Button x="367" y="272" label="全 屏" width="74" height="38" fontSize="20" click="button1_clickHandler(event)"/>
<s:Label x="291" y="82" text="标签" height="24" width="162" fontSize="20" id="id1"/>
<s:Label x="291" y="141" text="标签" width="162" height="24" fontSize="20" id="id2"/>
</s:Application>
<s:Application 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="#5C5A5A" width="550" height="338">
<fx:Script>
<![CDATA[
import flash.display.StageDisplayState;
protected function button1_clickHandler(event:MouseEvent):void
{
switch (stage.displayState) {
case StageDisplayState.FULL_SCREEN:
stage.displayState = StageDisplayState.NORMAL;
break;
default:
stage.displayState = StageDisplayState.FULL_SCREEN;
break;
}
id1.text = stage.displayState;
id2.text = stage.height.toString();
}
]]>
</fx:Script>
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Button x="367" y="272" label="全 屏" width="74" height="38" fontSize="20" click="button1_clickHandler(event)"/>
<s:Label x="291" y="82" text="标签" height="24" width="162" fontSize="20" id="id1"/>
<s:Label x="291" y="141" text="标签" width="162" height="24" fontSize="20" id="id2"/>
</s:Application>
近期项目使用flex3实现,一年多没用了,突然用到这玩意,感觉有点陌生了。今天要用代码实现flex3的全屏模式。这里有几个步骤需要注意:
修改html-template目录下的index.template.html文件,注意添加或修改红色字体部分
第一处:
修改html-template目录下的index.template.html文件,注意添加或修改红色字体部分
第一处:
AC_FL_RunContent(
"src", "playerProductInstall",
"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
"width", "${width}",
"height", "${height}",
"align", "middle",
"id", "${application}",
"quality", "high",
"bgcolor", "${bgcolor}",
"name", "${application}",
"allowFullScreen","true",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
第二处:"src", "playerProductInstall",
"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
"width", "${width}",
"height", "${height}",
"align", "middle",
"id", "${application}",
"quality", "high",
"bgcolor", "${bgcolor}",
"name", "${application}",
"allowFullScreen","true",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
AC_FL_RunContent(
"src", "${swf}",
"width", "${width}",
"height", "${height}",
"align", "middle",
"id", "${application}",
"quality", "high",
"bgcolor", "${bgcolor}",
"name", "${application}",
"allowFullScreen","true",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
第三处:"src", "${swf}",
"width", "${width}",
"height", "${height}",
"align", "middle",
"id", "${application}",
"quality", "high",
"bgcolor", "${bgcolor}",
"name", "${application}",
"allowFullScreen","true",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="${application}" width="${width}" height="${height}"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="${swf}.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="${bgcolor}" />
<param name="allowScriptAccess" value="sameDomain" />
<embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}"
width="${width}" height="${height}" name="${application}" align="middle"
play="true"
loop="false"
quality="high"
allowFullScreen="true"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>
id="${application}" width="${width}" height="${height}"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="${swf}.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="${bgcolor}" />
<param name="allowScriptAccess" value="sameDomain" />
<embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}"
width="${width}" height="${height}" name="${application}" align="middle"
play="true"
loop="false"
quality="high"
allowFullScreen="true"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>
最后:
全屏AS代码:
stage.displayState=StageDisplayState.FULL_SCREEN;
退出全屏AS代码:
stage.displayState=StageDisplayState.NORMAL;