FLEX2和FLEX3全屏的代码

一.flex2的全屏代码

在仅仅使用Flex Builder2(我下载的是FLXB_2.0_Win_WWE.exe)的时候,写全屏代码竟然找不到flash.display.StageDisplayState,于是下载了Flex <st1:chsdate w:st="on" isrocdate="False" year="1899" day="30" islunardate="False" month="12">2.0.1</st1:chsdate>升级包(官方地址:http://download.macromedia.com/pub/flex/flex_builder/flexbuilder2_201updater.exe)和Flex 2.0.1 Hotfix 2(官方地址:http://www.adobe.com/support/flex/ts/documents/flex2_hf2/FB2_Hotfix2_Installer_Win.exe),然后再更新flashplayer9。(参考:http://www.adobe.com/devnet/flashplayer/articles/full_screen_mode.html),下载了templates for Flex Builder,覆盖到flex项目的html-template目录下。全屏代码可以正常运行了。

代码

  1. <!---->xml version="1.0" encoding="utf-8"?>  
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"  
  3.     backgroundGradientColors="[#8080ff, #400040]">  
  4.        
  5.     <mx:Script>  
  6.         <!----> 
  7.         import flash.display.StageDisplayState;  
  8.  
  9.         private function toggle():void{  
  10.             if(fs.selected == true){  
  11.                 this.goFullScreen();  
  12.             } else {  
  13.                 this.exitFullScreen();  
  14.             }  
  15.         }  
  16.           
  17.         private function goFullScreen():void {  
  18.                stage.displayState = StageDisplayState.FULL_SCREEN;  
  19.         }  
  20.         private function exitFullScreen():void {  
  21.                stage.displayState = StageDisplayState.NORMAL;  
  22.         }  
  23.         ]]>  
  24.     mx:Script>  
  25.        
  26.     <mx:Panel width="100%" height="100%" title="轻松实现全屏"    
  27. layout="absolute">  
  28.         <mx:CheckBox label="全屏" id="fs" click="this.toggle()"    
  29.     horizontalCenter="0" verticalCenter="0"/>  
  30.     mx:Panel>  
  31.        
  32. mx:Application>  

 二.FLEX3全屏代码(转贴)

原文地址:http://www.duzengqiang.com/blog/article.asp?id=336 杜增强的博客

有网友说Felx2里面的全屏显示代码不能用了,因为flex3里面没有flash.display.StageDisplayState,
其实只要稍作修改就可以了

FullScree.mxml代码
<!---->
<mx:application xmlns:mx="&amp;lt;a href=" www.adobe.com="">http://www.adobe.com/2006/mxml"
    backgroundGradientColors="[#8080ff, #400040]">  
    <mx:script>
        <!---->        import flash.display.Stage;
        private function toggle():void{
            if(fs.selected == true){
                this.goFullScreen();
            } else {
                this.exitFullScreen();
            }
        }      
        private function goFullScreen():void {
               stage.displayState = 'fullScreen';
        }
        private function exitFullScreen():void {
               stage.displayState = 'normal';
        }
        ]]>
    </mx:script>
   
    <mx:panel title="轻松实现全屏" width="100%" height="100%"></mx:panel>layout="absolute">
        <mx:checkbox id="fs" label="全屏" click="this.toggle()"></mx:checkbox>    horizontalCenter="0" verticalCenter="0"/>
       
</mx:application>

 

index.template.html代码(html-template文件夹下)

<!---->


<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<!---->
<link href="deeplinking/deeplinking.css" type="text/css" rel="stylesheet">
<!---->


<script src="AC_OETags.js" language="javascript"></script>

<!---->
<script src="deeplinking/deeplinking.js" language="javascript"></script>
<!---->

<style type="text/css">
body { margin: 0px; overflow:hidden }
</style>
<script language="JavaScript" type="text/javascript">
<!---->
</script>


<script language="JavaScript" type="text/javascript">
<!---->
</script>
<noscript></noscript>


增加allowFullScreen="true"这个参数
如下:

<!-- saved from url=(0014)about:internet -->
<html lang="en">

<!--
Smart developers always View Source.

This application was built using Adobe Flex, an open source framework
for building rich Internet applications that get delivered via the
Flash Player or to desktops via Adobe AIR.

Learn more about Flex at http://flex.org
// -->

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!--  BEGIN Browser History required section -->
<link rel="stylesheet" type="text/css" href="history/history.css" />
<!--  END Browser History required section -->

<title>${title}</title>
<script src="AC_OETags.js" language="javascript"></script>

<!--  BEGIN Browser History required section -->
<script src="history/history.js" language="javascript"></script>
<!--  END Browser History required section -->

<style>
body { margin: 0px; overflow:hidden }
</style>
<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = ${version_major};
// Minor version of Flash required
var requiredMinorVersion = ${version_minor};
// Minor version of Flash required
var requiredRevision = ${version_revision};
// -----------------------------------------------------------------------------
// -->
</script>
</head>

<body scroll="no">
<script language="JavaScript" type="text/javascript">
<!--
// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
var hasProductInstall = DetectFlashVer(6, 0, 65);

// Version check based upon the values defined in globals
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

if ( hasProductInstall && !hasRequestedVersion ) {
 // DO NOT MODIFY THE FOLLOWING FOUR LINES
 // Location visited after installation is complete if installation is required
 var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
 var MMredirectURL = window.location;
    document.title = document.title.slice(0, 47) + " - Flash Player Installation";
    var MMdoctitle = document.title;

 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"
 );
} else if (hasRequestedVersion) {
 // if we've detected an acceptable version
 // embed the Flash Content SWF when all tests are passed
 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"
 );
  } else {  // flash is too old or we can't detect the plugin
    var alternateContent = 'Alternate HTML content should be placed here. '
   + 'This content requires the Adobe Flash Player. '
    + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
    document.write(alternateContent);  // insert non-flash content
  }
// -->
</script>
<noscript>
   <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="allowFullScreen" value="true" />
   <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>
</noscript>
</body>
</html>

你可能感兴趣的:(JavaScript,css,Flex,Flash,Adobe)