如何修复 stage.stageWidth 和 stageHeight 在 Firefox 3.5 上被识别?

发布于 2024-09-04 02:42:02 字数 3431 浏览 3 评论 0原文

在个人完整的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

守望孤独 2024-09-11 02:42:02

我使用 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!
  }

I use an ENTER_FRAME handler to listen until 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!
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文