·您当前的位置:首页 > 技术教程 > AS2与AS3技术 >

[AS3]as3自适应屏幕宽高的源代码实例(2)

时间:2014-08-20 13:59酷播
第二步:改变swf文件的html页面 html xmlns = http://www.w3.org/1999/xhtml head meta http-equiv = Content-Type content = text/html;charset=UTF-8 title 酷播技术 / title script src = AC_OETags.js language

第二步:改变swf文件的html页面

  1. <html xmlns="http://www.w3.org/1999/xhtml"><head>  
  2.  
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
  4. <title>酷播技术</title> 
  5. <script src="AC_OETags.js" language="javascript"></script> 
  6. <script language="javascript"> 
  7. setTimeout("exchangePage();", 1000*4); 
  8. function exchangePage() 
  9. { 
  10.     var t1_obj = document.getElementById('t1'); 
  11.     t1_obj.style.width = '100%'; 
  12.     t1_obj.style.height = '100%'; 
  13. } 
  14. </script> 
  15. <style> 
  16. *{margin:0px; padding:0px;} 
  17. body{ 
  18. margin:0px auto; 
  19. overflow:auto; 
  20. background:#000000; 
  21. height:100%; 
  22. text-align: center; 
  23. } 
  24. #content{margin:0px auto; width:100%; height:100%; text-align:center;} 
  25. #t1{width:1px; height:1px;} 
  26. .temp{color:#FFF; font-size:14px; text-align:left; width:250px; margin:0px auto;} 
  27. </style> 
  28. </head> 
  29. <body> 
  30. <div style="width: 1250px; height: 650px; overflow:hidden; " id="content" align="center"> 
  31. <div style="width: 1250px; height: 650px; overflow:hidden; " id="t1"> 
  32. <script language="JavaScript" type="text/javascript"> 
  33. var requiredMajorVersion = 10; 
  34. var requiredMinorVersion = 0; 
  35. var requiredRevision = 0; 
  36.  
  37. var Config = { 
  38.         'service_url':  'http://www.cuplayer.com/service/service', 
  39.         'bbs_url':      'http://bbs.cuplayer.com/forum-112-1.html', 
  40.         'event_url':    'http://tt.cuplayer.com/index/event', 
  41.         'home_url':     'http://tt.cuplayer.com/', 
  42.         'save_url':     'http://tt.cuplayer.com/', 
  43.         'vip_url':      'http://tt.cuplayer.com/index/content/cid/115/id/724', 
  44.         'payment_url':  'http://www.cuplayer.com/payment/payment/payment', 
  45.         'adult_check_url':      'http://www.cuplayer.com/member/member/idcard' 
  46. }; 
  47.  
  48. function writeFlashObject(swf_src, param_str)  
  49. { 
  50.     document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"100%\" height=\"100%\" id=\"wGame\" align=\"middle\"\>\n"); 
  51.     document.write("<param name=\"allowScriptAccess\" value=\"always\" /\>\n"); 
  52.     document.write("<param name=\"movie\" value=\""+ swf_src +"\" /\>\n"); 
  53.     document.write("<param name=\"allowFullScreen\" value=\"true\" />"); 
  54.     document.write("<param name=\"WMode\" value=\"Transparent\">"); 
  55.     document.write("<param name=\"FlashVars\" value=\""+ param_str +"\" /\>\n"); 
  56.     document.write("<param name=\"quality\" value=\"high\" /\>\n"); 
  57.     document.write("<param name=\"bgcolor\" value=\"#000000\" /\>\n"); 
  58.     document.write("<embed src=\""+ swf_src +"\" quality=\"high\" bgcolor=\"#000000\" width=\"100%\" height=\"100%\" name=\"wGame\" align=\"middle\" allowScriptAccess=\"always\" FlashVars=\""+ param_str +"\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /\>"); 
  59.     document.write("</object\>"); 
  60. } 
  61.  
  62. //<!-- 
  63. // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65) 
  64. var hasProductInstall = DetectFlashVer(6, 0, 65); 
  65.  
  66. // Version check based upon the values defined in globals 
  67. var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision); 
  68. // document.write("如果显示了这段文字,那么您的浏览器支持 JavaScript") 
  69. if ( hasProductInstall && !hasRequestedVersion ) { 
  70.     // DO NOT MODIFY THE FOLLOWING FOUR LINES 
  71.     // Location visited after installation is complete if installation is required 
  72.     var alternateContent = '<div class="temp"><p>您的flash版本过低,需要升级才能获得更好的游戏体验。</p>' 
  73.         +'<p><b>#下载链接:</b></p>' 
  74.         +'<p><a href="http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player.exe">最新版</a></p>' 
  75.         +'<p><a href="http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_ax_debug.exe">最新版 (IE)</a></p>' 
  76.         +'<p><a href="http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_plugin_debug.exe">最新版 (非IE)</a></p>' 
  77.         +'<p>最新版Flash Player在线安装:<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">IE</a>、<a href="http://www.adobe.com/shockwave/download/alternates/" target="_blank">非IE</a></p></div>'; 
  78.     document.write(alternateContent);  // insert non-flash content 
  79. } else if (hasRequestedVersion) { 
  80. writeFlashObject("Main.swf?version=TianTu-1.6.0-r10859-release", "serid=9&res=http://ttcdn.92haowan.com/TianTu_release_r10885⟨=zh_CN&web=http://tt4.92haowan.com&gatewaygateway=gateway.php&svrip=tt4.92haowan.com&svrport=39000&version=TianTu-1.6.0-r10859-release&auth_key=8b8a851cbec1351afa1a2ec48c40472f&service_url=http%3A%2F%2Fwww.92haowan.com%2Fservice%2Fservice&bbs_url=http%3A%2F%2Fbbs.92haowan.com%2Fforum-112-1.html&event_url=http%3A%2F%2Ftt.92haowan.com%2Findex%2Fevent&home_url=http%3A%2F%2Ftt.92haowan.com%2F&save_url=http%3A%2F%2Ftt.92haowan.com%2F&vip_url=http%3A%2F%2Ftt.92haowan.com%2Findex%2Fcontent%2Fcid%2F115%2Fid%2F724&payment_url=http%3A%2F%2Fwww.92haowan.com%2Fpayment%2Fpayment%2Fpayment&adult_check_url=http%3A%2F%2Fwww.92haowan.com%2Fmember%2Fmember%2Fidcard&guide_map_id=48&adult_mark=0")} else {  // flash is too old or we can't detect the plugin 
  81.     var alternateContent = '<div class="temp"><p>您还未安装flash,请下载安装后进行游戏。</p>' 
  82.         +'<p><b>#下载链接:</b></p>' 
  83.         +'<p><a href="http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player.exe">最新版</a></p>' 
  84.         +'<p><a href="http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_ax_debug.exe">最新版 (IE)</a></p>' 
  85.         +'<p><a href="http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_plugin_debug.exe">最新版 (非IE)</a></p>' 
  86.         +'<p>最新版Flash Player在线安装:<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">IE</a>、<a href="http://www.adobe.com/shockwave/download/alternates/" target="_blank">非IE</a></p></div>'; 
  87.     document.write(alternateContent);  // insert non-flash content 
  88. } 
  89.  
  90. // --> 
  91. </script><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" name="wGame" width="100%" height="100%" align="middle" id="wGame"> 
  92. <param name="allowScriptAccess" value="always"> 
  93. <param name="movie" value="Main.swf?version=TianTu-1.6.0-r10859-release"> 
  94. <param name="FlashVars" value="serid=9&res=http://ttcdn.92haowan.com/TianTu_release_r10885&lang=zh_CN&web=http://tt4.92haowan.com&gateway=gateway.php&svrip=tt4.92haowan.com&svrport=39000&version=TianTu-1.6.0-r10859-release&auth_key=8b8a851cbec1351afa1a2ec48c40472f&service_url=http%3A%2F%2Fwww.92haowan.com%2Fservice%2Fservice&bbs_url=http%3A%2F%2Fbbs.92haowan.com%2Fforum-112-1.html&event_url=http%3A%2F%2Ftt.92haowan.com%2Findex%2Fevent&home_url=http%3A%2F%2Ftt.92haowan.com%2F&save_url=http%3A%2F%2Ftt.92haowan.com%2F&vip_url=http%3A%2F%2Ftt.92haowan.com%2Findex%2Fcontent%2Fcid%2F115%2Fid%2F724&payment_url=http%3A%2F%2Fwww.92haowan.com%2Fpayment%2Fpayment%2Fpayment&adult_check_url=http%3A%2F%2Fwww.92haowan.com%2Fmember%2Fmember%2Fidcard&guide_map_id=48&adult_mark=0"> 
  95. <param name="quality" value="high"> 
  96. <param name="bgcolor" value="#000000"> 
  97. <param name="allowFullScreen" value="true" /> 
  98. <param name="WMode" value="Transparent"> 
  99. <embed src="Main.swf" quality="high" bgcolor="#000000" name="wGame" allowscriptaccess="always" flashvars="serid=9&res=http://ttcdn.92haowan.com/TianTu_release_r10885&lang=zh_CN&web=http://tt4.92haowan.com&gateway=gateway.php&svrip=tt4.92haowan.com&svrport=39000&version=TianTu-1.6.0-r10859-release&auth_key=8b8a851cbec1351afa1a2ec48c40472f&service_url=http%3A%2F%2Fwww.92haowan.com%2Fservice%2Fservice&bbs_url=http%3A%2F%2Fbbs.92haowan.com%2Fforum-112-1.html&event_url=http%3A%2F%2Ftt.92haowan.com%2Findex%2Fevent&home_url=http%3A%2F%2Ftt.92haowan.com%2F&save_url=http%3A%2F%2Ftt.92haowan.com%2F&vip_url=http%3A%2F%2Ftt.92haowan.com%2Findex%2Fcontent%2Fcid%2F115%2Fid%2F724&payment_url=http%3A%2F%2Fwww.92haowan.com%2Fpayment%2Fpayment%2Fpayment&adult_check_url=http%3A%2F%2Fwww.92haowan.com%2Fmember%2Fmember%2Fidcard&guide_map_id=48&adult_mark=0" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="100%" align="middle" height="100%"></object> 
  100. </div> 
  101.  
  102. <script language="javascript" type="text/javascript">  
  103. //flash窗口大小设置 
  104. function resizeBrowser() 
  105. { 
  106. var max_width = 1250; 
  107. var max_height= 650; 
  108. contentObj = document.getElementById('content'); 
  109. var bodyWidth = (window.innerWidth) ? window.innerWidth : (document.body && document.body.clientWidth) ? document.body.clientWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.offsetWidth;  
  110. var bodyHeight = (window.innerHeight) ? window.innerHeight : (document.body && document.body.clientHeight) ? document.body.clientHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight;  
  111. if (bodyWidth > max_width)  
  112. { 
  113.     contentObj.style.width = max_width + 'px'; 
  114. } 
  115. else 
  116. { 
  117.     contentObj.style.width = '100%'; 
  118. } 
  119. if (bodyHeight > max_height) 
  120. { 
  121.     contentObj.style.height = max_height + 'px'; 
  122. } 
  123. else 
  124. { 
  125.     contentObj.style.height = '100%'; 
  126. } 
  127. if (document.getElementById('wGame')) 
  128. { 
  129.     document.getElementById('wGame').focus(); 
  130. } 
  131. } 
  132. resizeBrowser(); 
  133. window.onresize=resizeBrowser; 
  134. </script> 
  135. <noscript> 
  136. 您的的浏览器不支持JavaScript,请从打开相关设置。 
  137. </noscript> 
  138. </div></body></html> 

 

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器