如何解决在Firefox 3.5上识别stage.stageWidth和stageHeight?

问题描述:

在个人全闪存网站上工作,我无法真正弄清楚如何让MC在Firefox浏览器上对齐舞台上的位置。一切顺利使用Safari。如何解决在Firefox 3.5上识别stage.stageWidth和stageHeight?

我试过一个设置计时器的方法,每次它关闭(每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> 

我desesperated找到解决它的正道。这是我现在的代码:

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(); 
     } 

    } 
+0

等等,让我明白这一点,你正在研究一个“完整的Flash网站”*,而不需要*被上级强制这么做? – 2010-06-03 17:00:48

我使用ENTER_FRAME处理函数来监听,直到stage.stageWidth > 0 && stage.stageHeight > 0

public function Main() 
    { 
     addEventListener(Event.ENTER_FRAME, enter_frame); 
    } 

    private function enter_frame(e:Event) 
    { 
    if (stage.stageWidth > 0 && stage.stageHeight > 0) 
    { 
     removeEventListener(Event.ENTER_FRAME, enter_frame); 
     init(); 
    } 
    } 

    private function init() 
    { 
    // GOOD TO GO! 
    }