·您当前的位置:首页 > 技术教程 > 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.     var t1_obj = document.getElementById('t1'); 
  10.     t1_obj.style.width = '100%'
  11.     t1_obj.style.height = '100%'
  12. </script> 
  13. <style> 
  14. *{margin:0px; padding:0px;} 
  15. body{ 
  16. margin:0px auto; 
  17. overflow:auto; 
  18. background:#000000; 
  19. height:100%; 
  20. text-align: center; 
  21. #content{margin:0px auto; width:100%; height:100%; text-align:center;} 
  22. #t1{width:1px; height:1px;} 
  23. .temp{color:#FFF; font-size:14px; text-align:left; width:250px; margin:0px auto;} 
  24. </style> 
  25. </head> 
  26. <body> 
  27. <div style="width: 1250px; height: 650px; overflow:hidden; " id="content" align="center"> 
  28. <div style="width: 1250px; height: 650px; overflow:hidden; " id="t1"> 
  29. <script language="JavaScript" type="text/javascript"> 
  30. var requiredMajorVersion = 10
  31. var requiredMinorVersion = 0
  32. var requiredRevision = 0
  33.  
  34. var Config = { 
  35.         'service_url':  'http://www.cuplayer.com/service/service', 
  36.         'bbs_url':      'http://bbs.cuplayer.com/forum-112-1.html', 
  37.         'event_url':    'http://tt.cuplayer.com/index/event', 
  38.         'home_url':     'http://tt.cuplayer.com/', 
  39.         'save_url':     'http://tt.cuplayer.com/', 
  40.         'vip_url':      'http://tt.cuplayer.com/index/content/cid/115/id/724', 
  41.         'payment_url':  'http://www.cuplayer.com/payment/payment/payment', 
  42.         'adult_check_url':      'http://www.cuplayer.com/member/member/idcard' 
  43. }; 
  44.  
  45. function writeFlashObject(swf_src, param_str)  
  46.     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"); 
  47.     document.write("<param name=\"allowScriptAccess\" value=\"always\" /\>\n"); 
  48.     document.write("<param name=\"movie\" value=\""+ swf_src +"\" /\>\n"); 
  49.     document.write("<param name=\"allowFullScreen\" value=\"true\" />"); 
  50.     document.write("<param name=\"WMode\" value=\"Transparent\">"); 
  51.     document.write("<param name=\"FlashVars\" value=\""+ param_str +"\" /\>\n"); 
  52.     document.write("<param name=\"quality\" value=\"high\" /\>\n"); 
  53.     document.write("<param name=\"bgcolor\" value=\"#000000\" /\>\n"); 
  54.     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\" /\>"); 
  55.     document.write("</object\>"); 
  56.  
  57. //<!-- 
  58. // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65) 
  59. var hasProductInstall = DetectFlashVer(6, 0, 65); 
  60.  
  61. // Version check based upon the values defined in globals 
  62. var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision); 
  63. // document.write("如果显示了这段文字,那么您的浏览器支持 JavaScript") 
  64. if ( hasProductInstall && !hasRequestedVersion ) { 
  65.     // DO NOT MODIFY THE FOLLOWING FOUR LINES 
  66.     // Location visited after installation is complete if installation is required 
  67.     var alternateContent = '<div class="temp"><p>您的flash版本过低,需要升级才能获得更好的游戏体验。</p>' 
  68.         +'<p><b>#下载链接:</b></p>
  69.         +'<p><a href="http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player.exe">最新版</a></p>
  70.         +'<p><a href="http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_ax_debug.exe">最新版 (IE)</a></p>
  71.         +'<p><a href="http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_plugin_debug.exe">最新版 (非IE)</a></p>
  72.         +'<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>'; 
  73.     document.write(alternateContent);  // insert non-flash content 
  74. } else if (hasRequestedVersion) { 
  75. 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 
  76.     var alternateContent = '<div class="temp"><p>您还未安装flash,请下载安装后进行游戏。</p>' 
  77.         +'<p><b>#下载链接:</b></p>
  78.         +'<p><a href="http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player.exe">最新版</a></p>
  79.         +'<p><a href="http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_ax_debug.exe">最新版 (IE)</a></p>
  80.         +'<p><a href="http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_plugin_debug.exe">最新版 (非IE)</a></p>
  81.         +'<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>'; 
  82.     document.write(alternateContent);  // insert non-flash content 
  83.  
  84. // --> 
  85. </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"> 
  86. <param name="allowScriptAccess" value="always"> 
  87. <param name="movie" value="Main.swf?version=TianTu-1.6.0-r10859-release"> 
  88. <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"> 
  89. <param name="quality" value="high"> 
  90. <param name="bgcolor" value="#000000"> 
  91. <param name="allowFullScreen" value="true" /> 
  92. <param name="WMode" value="Transparent"> 
  93. <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> 
  94. </div> 
  95.  
  96. <script language="javascript" type="text/javascript">  
  97. //flash窗口大小设置 
  98. function resizeBrowser() 
  99. var max_width = 1250
  100. var max_height650
  101. contentObj = document.getElementById('content'); 
  102. 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;  
  103. 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;  
  104. if (bodyWidth > max_width)  
  105.     contentObj.style.width = max_width + 'px'; 
  106. else 
  107.     contentObj.style.width = '100%'
  108. if (bodyHeight > max_height) 
  109.     contentObj.style.height = max_height + 'px'; 
  110. else 
  111.     contentObj.style.height = '100%'
  112. if (document.getElementById('wGame')) 
  113.     document.getElementById('wGame').focus(); 
  114. resizeBrowser(); 
  115. window.onresize=resizeBrowser
  116. </script> 
  117. <noscript> 
  118. 您的的浏览器不支持JavaScript,请从打开相关设置。 
  119. </noscript> 
  120. </div></body></html> 

 

热门文章推荐

请稍候...

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

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