我正在使用swfobject将swf嵌入到网页中。
var params = {};
params['movie'] = 'player.swf';
params['wmode'] = 'transparent';
params['bgcolor'] = 'ffffff';
params['allowScriptAccess'] = 'always';
params['allowFullScreen'] = 'true';
var flashvars = {};
flashvars['url'] = 'video.flv';
flashvars['resize'] = 'fit-player';
swfobject.embedSWF("player.swf", "video", "480", "340", "10.1.0", null, flashvars, params);
这会创建以下HTML(我在FF3.6中进行测试,因此实际HTML可能会有所不同,具体取决于您的浏览器,但它应该足够接近):
<object width="480" height="340" type="application/x-shockwave-flash" data="EmbeddedPlayer.swf" id="video" style="visibility: visible;">
<param name="wmode" value="transparent">
<param name="bgcolor" value="ffffff">
<param name="allowScriptAccess" value="always">
<param name="allowFullScreen" value="true">
<param name="flashvars" value="url=MD-Open_ProblemOne_1000k_part2.flv&resize=fit-player">
</object>
我正试图找到一种从AS3中获取'width'和'height'属性的好方法。 stage.stageWidth
返回在CS5中定义的宽度,stage.width返回其子节点的组合维度/位置的宽度,LoaderInfo(this.root.loaderInfo).width
引发以下错误:
Error: Error #2099: The loading object is not sufficiently loaded to provide this information.
非常感谢任何帮助!
答案 0 :(得分:2)
只需使用stage.width
和stage.height
即可。它们返回嵌入式闪光灯的整个宽度和高度,而不是闪光灯中设置的舞台宽度和高度。
答案 1 :(得分:0)
在flashvars中从JS传递宽度:
....
var flashvars = {};
flashvars['url'] = 'video.flv';
flashvars['resize'] = 'fit-player';
flashvars['height'] = '340';
flashvars['resize'] = '480';
swfobject.embedSWF("player.swf", "video", "480", "340", "10.1.0", null, flashvars, params);