如何讓flash做到自動縮放(How to make a Flash SWF file auto-fit into the screen or web browser)
例如我引用一個flash範例檔如下
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JS Bin</title> </head> <body> <div class="row"> <script language="javascript"> var aFiles = new Array(); if (AC_FL_RunContent == 0) { alert('This page requires AC_RunActiveContent.js.'); } else { AC_FL_RunContent( 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0', 'width', '1000', 'height', '250', 'src', '/db/flash/flash6', 'quality', 'high', 'pluginspage', 'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash', 'align', 'middle', 'play', 'true', 'loop', 'true', 'scale', 'noscale', 'wmode', 'transparent', 'devicefont', 'false', 'id', 'swf_News', 'bgcolor', '#ffffff', 'name', 'swf_News', 'menu', 'true', 'allowFullScreen', 'false', 'allowScriptAccess', 'always', 'movie', '/db/flash/flash6', 'FlashVars', '', 'salign', 'lt' ); //end AC code } </script> <embed src="https://s.yimg.com/cv/ae/tw/bwchou/bb_O-251497_150512b_970x250.swf" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" align="middle" play="true" loop="true" scale="noscale" wmode="transparent" devicefont="false" bgcolor="#ffffff" quality="high" name="swf_News" menu="true" allowfullscreen="false" allowscriptaccess="always" flashvars="" salign="lt" width="1000" height="250" type="application/x-shockwave-flash"> </div> </body> </html>
實際呈現如下圖
如果模擬在手機觀看時將會發現圖片會因為視窗寬度不足而被隱藏。
可以修改scale參數,改成exactfit或default來自動縮放,
exactfit範例如下
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JS Bin</title> </head> <body> <div class="row"> <script language="javascript"> var aFiles = new Array(); if (AC_FL_RunContent == 0) { alert('This page requires AC_RunActiveContent.js.'); } else { AC_FL_RunContent( 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0', 'width', '100%', 'height', '100%', 'src', '/db/flash/flash6', 'quality', 'high', 'pluginspage', 'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash', 'align', 'middle', 'play', 'true', 'loop', 'true', 'scale', 'exactfit', 'wmode', 'transparent', 'devicefont', 'false', 'id', 'swf_News', 'bgcolor', '#ffffff', 'name', 'swf_News', 'menu', 'true', 'allowFullScreen', 'false', 'allowScriptAccess', 'always', 'movie', '/db/flash/flash6', 'FlashVars', '', 'salign', 'lt' ); //end AC code } </script> <embed src="https://s.yimg.com/cv/ae/tw/bwchou/bb_O-251497_150512b_970x250.swf" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" align="middle" play="true" loop="true" scale="exactfit" wmode="transparent" devicefont="false" bgcolor="#ffffff" quality="high" name="swf_News" menu="true" allowfullscreen="false" allowscriptaccess="always" flashvars="" salign="lt" width="100%" height="100%" type="application/x-shockwave-flash"> </div> </body> </html>
實際呈現如下圖
但是這功能會讓圖不按長寬比的縮放
但改成default時則
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JS Bin</title> </head> <body> <div class="row"> <script language="javascript"> var aFiles = new Array(); if (AC_FL_RunContent == 0) { alert('This page requires AC_RunActiveContent.js.'); } else { AC_FL_RunContent( 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0', 'width', '100%', 'height', '100%', 'src', '/db/flash/flash6', 'quality', 'high', 'pluginspage', 'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash', 'align', 'middle', 'play', 'true', 'loop', 'true', 'scale', 'default', 'wmode', 'transparent', 'devicefont', 'false', 'id', 'swf_News', 'bgcolor', '#ffffff', 'name', 'swf_News', 'menu', 'true', 'allowFullScreen', 'false', 'allowScriptAccess', 'always', 'movie', '/db/flash/flash6', 'FlashVars', '', 'salign', 'lt' ); //end AC code } </script> <embed src="https://s.yimg.com/cv/ae/tw/bwchou/bb_O-251497_150512b_970x250.swf" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" align="middle" play="true" loop="true" scale="default" wmode="transparent" devicefont="false" bgcolor="#ffffff" quality="high" name="swf_News" menu="true" allowfullscreen="false" allowscriptaccess="always" flashvars="" salign="lt" width="100%" height="100%" type="application/x-shockwave-flash"> </div> </body> </html>
則會按照正常比例做縮放
參考資料:
How to make a Flash SWF file auto-fit into the screen or web browser?
Flash Professional Help / Flash OBJECT and EMBED tag attributes