我的Actionscript 3网站遇到了这个问题。基本上,它是背景元素(电影剪辑),应该调整大小以覆盖舞台。但是,这不会发生。浏览器窗口确实是舞台的颜色(深灰色),但MC在左上角保持默认大小。
在Flash CS5中测试时一切正常。在发布并在浏览器中打开它之后,问题就出现了。
我很困惑,没有找到更多关于此的信息,因为我认为每个拥有自动调整大小内容的Flash网站都必须以某种方式解决这个问题。
下面是一个简单的例子,说明了这个问题:
import flash.events.Event;
import flash.display.MovieClip;
import fl.text.TLFTextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
var back:MovieClip;
var email:TLFTextField;
var coming:TLFTextField;
var count:TLFTextField;
var i:int;
init();
function init():void {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
back = new MovieClip();
email = new TLFTextField();
coming = new TLFTextField();
count = new TLFTextField();
email.text = "address@host.com";
configureTextField(email);
coming.text = "coming soon";
configureTextField(coming);
i = 0;
count.text = "" + i + " " + stage.stageWidth + " " + stage.stageHeight;
configureTextField(count);
back.graphics.beginFill(0x330000, 1);
back.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
back.graphics.endFill();
back.addEventListener(Event.ADDED_TO_STAGE, addHandler, false, 0, true);
stage.addChild(back);
stage.addChild(email);
stage.addChild(coming);
stage.addChild(count);
stage.dispatchEvent(new Event(Event.RESIZE));
}
function addHandler(event:Event):void {
stage.addEventListener(Event.RESIZE, resizeHandler);
back.removeEventListener(Event.ADDED_TO_STAGE, addHandler);
}
function configureTextField(currentText:TLFTextField):void {
var format = new TextFormat();
format.font = "Calibri";
format.size = 24;
format.color = 0xFFFFFF;
currentText.setTextFormat(format);
currentText.autoSize = TextFieldAutoSize.LEFT;
currentText.selectable = false;
}
function resizeHandler(event:Event):void {
back.width = stage.stageWidth;
back.height = stage.stageHeight;
email.x = stage.stageWidth/2 - email.width/2;
email.y = stage.stageHeight/2;
coming.x = stage.stageWidth/2 - coming.width/2;
coming.y = stage.stageHeight/2 - 64;
count.x = stage.stageWidth/2 - count.width/2;
count.y = stage.stageHeight/2 + 64;
i++;
count.text = "" + i + " " + stage.stageWidth + " " + stage.stageHeight;
configureTextField(count);
}
部分已发布的HTML代码,如果有帮助的话:
<head>
<title>comingSoon</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
html, body { height:100%; background-color: #333333;}
body { margin:0; padding:0; overflow:hidden; }
#flashContent { width:100%; height:100%; }
</style>
</head>
<body>
<div id="flashContent">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="800" height="800" id="comingSoon" align="middle">
<param name="movie" value="comingSoon.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#333333" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="comingSoon.swf" width="800" height="800">
<param name="movie" value="comingSoon.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#333333" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--<![endif]-->
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
</body>
</html>
非常感谢任何建议!
谢谢!
CC
答案 0 :(得分:1)
您应该将对象标记的宽度和高度设置为100%。
所以改变:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="800" height="800" id="comingSoon" align="middle">
代表
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%" height="100%" id="comingSoon" align="middle">
同样改变:
<object type="application/x-shockwave-flash" data="comingSoon.swf" width="800" height="800">
的
<object type="application/x-shockwave-flash" data="comingSoon.swf" width="100%" height="100%">