2010-06-03 19 views
0

在個人全閃存網站上工作,我無法真正弄清楚如何讓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

回答

0

我使用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! 
    } 
相關問題