我使用swfObject并使用100%嵌入我的对象作为宽度和高度值。 我的外部div中的宽度和高度设置为500。
然而我的swf只占宽度的100%,而不是高度。
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript">
var currentVid;
$(document).ready(function(){
//This parameter will name the file
callRecorder("test001");
});
function callRecorder(x){
currentVid = x;
var flashvars = {};
flashvars.fileName=x;
var parameters = {};
var attributes = {};
attributes.name="vidRecorder";
attributes.id="vidRecorder";
swfobject.embedSWF("recorder.swf?ID="+Math.random()*100,"vidRecorderDIV","100%","100%","11.2", "expressInstall.swf", flashvars, parameters, attributes);
}
</script>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" height="100%" creationComplete="getService()" skinClass="mySkin" frameRate="60" >
///
stage.scaleMode = StageScaleMode.EXACT_FIT;
答案 0 :(得分:0)
这是嵌入SWF时的常见问题。要使SWF填充100%高度的HTML元素,请确保父容器具有在CSS中显式声明的高度:
/* the parent of the vidRecorderDIV. I don't
know what the name is so I guessed
vidRecorderDIVparent. Replace with the
selector of the true parent element */
#vidRecorderDIVparent {
height: 500px;
margin: 0;
padding: 0;
}
#vidRecorderDIV {
height: 100%;
}
如果您的SWF是页面上的唯一内容,请确保body
和html
的高度设置为100%,没有填充或边距:
html {
height: 100%;
overflow: hidden; /* Hides scrollbar in IE */
}
body {
height: 100%;
margin: 0;
padding: 0;
}
#vidRecorderDIV {
height: 100%;
}
您可以在http://learnswfobject.com/advanced-topics/100-width-and-height-in-browser/
查看功能正常的示例另外,请注意swfobject.embedSWF
已经在domready
上执行,因此没有必要包装jQuery $(document).ready
函数(也不会因为离开jQuery而受伤)。< / p>