自适应显示FLASH

弄两个尺寸不同的flash分别是: 1.swf, 2.swf
在同目录的网页中如下测试:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29

,0" name="Flash1" width="50" height="50" id="Flash1" border="1">
  <param name="movie" value="1.swf">
  <param name="quality" value="high">
  <embed src="1.swf" width="50" height="50" quality="high"

pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-

flash" name="Flash1"></embed></object>
<br/>
<input type="button" value="1.swf" onclick="ch('1.swf')">
<input type="button" value="2.swf" onclick="ch('2.swf')">
<script language="JavaScript">
<!--
function ch(src){
Flash1.movie = src;
var w = Flash1.GetVariable("Stage.width");
var h = Flash1.GetVariable("Stage.height");
Flash1.width  = w;
Flash1.height = h;
}
//-->
</script>
就可以自适应尺寸了!
当然,你如果要自动的,而不是点击按钮才适应,可以这样:
<body onload="fixSizeFlash(Flash1)">
<script language="JavaScript">
<!--
function fixSizeFlash(Flash1){
var w = Flash1.GetVariable("Stage.width");
var h = Flash1.GetVariable("Stage.height");
Flash1.width  = w;
Flash1.height = h;
}
//-->
</script>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29

,0" name="Flash1" width="50" height="50" id="Flash1" border="1">
  <param name="movie" value="1.swf">
  <param name="quality" value="high">
  <embed src="1.swf" width="50" height="50" quality="high"

pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-

flash" name="Flash1"></embed></object>

你可能感兴趣的:(Flash)