如何修复 stage.stageWidth 和 stageHeight 在 Firefox 3.5 上被识别?
在个人完整的 Flash 网站上工作,我真的不知道如何使 MC 在 Stage 上的位置在 Firefox 浏览器上保持一致。使用 Safari 一切顺利。
我尝试过一种设置计时器的方法,每次关闭时(每 200 毫秒左右)它都会检查 stage.stageWidth > 。 0. 如果是这种情况,请停止计时器并开始在舞台上调整大小。但它仍然无法在 MAC 版 Firefox 上运行。 :(
在我的 HTML 代码中:
<link href="css/site.css" rel="stylesheet" type="text/css" />
测试站点
<script type="text/javascript">
var swf = new SWFObject("main.swf", "mymovie", "100%", "100%", "10", "#000000");
swf.addParam("allowScriptAccess", "always");
swf.addParam("scale", "noscale");
swf.write("flashcontent");
</script>
我迫切希望找到正确的方法来解决它。这是我当前的代码:
public function Main()
{
addEventListener(Event.ADDED_TO_STAGE, handleOnStage, false, 0, true);
}
private function handleOnStage(event:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, handleOnStage);
tabSWFLoader = Vector.<String>([INTRO_SWF, BOOK1_SWF, BOOK2_SWF, PERSONAL_SWF]);
menuItems = new MovieClip();
nextMC = new Sprite();
currentMC = new Sprite();
topBarMC = new BGTopBarMC();
bottomBarMC = new BGBottomBarMC();
logoMC = new Logo();
menuContainer = new MovieClip();
setReceiver();
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, handleResizeObjectsOnStage, false, 0, true);
// Set timer to start initialize objects on stage
stageTime = new Timer(200);
stageTime.addEventListener(TimerEvent.TIMER, handleTime, false, 0, true);
stageTime.start();
}
private function handleTime(event:TimerEvent):void
{
if (stage.stageWidth > 0 && stage.stageHeight > 0) {
initObjectsOnStage();
}
}
private function handleResizeObjectsOnStage(event:Event=null):void
{
if (stage.stageWidth > 0 && stage.stageHeight > 0) {
initObjectsOnStage();
}
}
private function initObjectsOnStage():void
{
if (!isReady) {
isReady = true;
stageTime.stop();
stage.removeEventListener(Event.RESIZE, handleResizeObjectsOnStage);
// Resize dynamically bottomBarMC
bottomBarMC.width = stage.stageWidth;
bottomBarMC.height = stage.stageHeight;
addChild(bottomBarMC);
bottomBarMC.x = 0;
bottomBarMC.y = stage.stageHeight - bottomBarMC.height;
// Resize dynamically logo
logoMC.x = 40;
logoMC.y = topBarMC.height+50;
addChild(logoMC);
// Add listener
logoMC.addEventListener(MouseEvent.CLICK, handleClickedLogo, false, 0, true);
// ** In Firefox doesn't show up this menu, couldn't recognize
menuContainer.x = 65;
menuContainer.y = 720;
addChild(menuContainer);
menuContainer.addChild(menu);
// Get objects from Menu class
menu.addEventListener(CustomEventCenter.OBJECT_USED, handleMenu, false, 0, true);
// Call intro method
initIntro();
}
}
Working on personal full flash site and I can't really figure out how to make MC's position on Stage aligned on Firefox browser. Everything goes fine using Safari.
I have tried a method of set a timer every time it goes off (every 200 ms or so) it checks to see if stage.stageWidth > 0. If that is the case, do stop the timer and start resize on stage. However it's still not working on Firefox of MAC. :(
In my HTML code:
<link href="css/site.css" rel="stylesheet" type="text/css" />
Test Site
<script type="text/javascript">
var swf = new SWFObject("main.swf", "mymovie", "100%", "100%", "10", "#000000");
swf.addParam("allowScriptAccess", "always");
swf.addParam("scale", "noscale");
swf.write("flashcontent");
</script>
I'm desesperated of finding the right way to fix it. Here's my current code:
public function Main()
{
addEventListener(Event.ADDED_TO_STAGE, handleOnStage, false, 0, true);
}
private function handleOnStage(event:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, handleOnStage);
tabSWFLoader = Vector.<String>([INTRO_SWF, BOOK1_SWF, BOOK2_SWF, PERSONAL_SWF]);
menuItems = new MovieClip();
nextMC = new Sprite();
currentMC = new Sprite();
topBarMC = new BGTopBarMC();
bottomBarMC = new BGBottomBarMC();
logoMC = new Logo();
menuContainer = new MovieClip();
setReceiver();
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, handleResizeObjectsOnStage, false, 0, true);
// Set timer to start initialize objects on stage
stageTime = new Timer(200);
stageTime.addEventListener(TimerEvent.TIMER, handleTime, false, 0, true);
stageTime.start();
}
private function handleTime(event:TimerEvent):void
{
if (stage.stageWidth > 0 && stage.stageHeight > 0) {
initObjectsOnStage();
}
}
private function handleResizeObjectsOnStage(event:Event=null):void
{
if (stage.stageWidth > 0 && stage.stageHeight > 0) {
initObjectsOnStage();
}
}
private function initObjectsOnStage():void
{
if (!isReady) {
isReady = true;
stageTime.stop();
stage.removeEventListener(Event.RESIZE, handleResizeObjectsOnStage);
// Resize dynamically bottomBarMC
bottomBarMC.width = stage.stageWidth;
bottomBarMC.height = stage.stageHeight;
addChild(bottomBarMC);
bottomBarMC.x = 0;
bottomBarMC.y = stage.stageHeight - bottomBarMC.height;
// Resize dynamically logo
logoMC.x = 40;
logoMC.y = topBarMC.height+50;
addChild(logoMC);
// Add listener
logoMC.addEventListener(MouseEvent.CLICK, handleClickedLogo, false, 0, true);
// ** In Firefox doesn't show up this menu, couldn't recognize
menuContainer.x = 65;
menuContainer.y = 720;
addChild(menuContainer);
menuContainer.addChild(menu);
// Get objects from Menu class
menu.addEventListener(CustomEventCenter.OBJECT_USED, handleMenu, false, 0, true);
// Call intro method
initIntro();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用 ENTER_FRAME 处理程序来侦听,直到 stage.stageWidth > 0 && stage.stageHeight > 0 。
I use an ENTER_FRAME handler to listen until
stage.stageWidth > 0 && stage.stageHeight > 0
.