首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复在Firefox3.5上被识别的stage.stageWidth和stageHeight?

如何修复在Firefox3.5上被识别的stage.stageWidth和stageHeight?
EN

Stack Overflow用户
提问于 2010-06-04 00:47:09
回答 1查看 1.1K关注 0票数 0

在个人全闪存网站上工作,我真的想不出如何让MC在舞台上的位置在Firefox浏览器上对齐。使用Safari一切都很顺利。

我尝试了一种方法,每次计时器关闭时(大约每隔200ms),它会检查stage.stageWidth是否> 0。如果是这种情况,请停止计时器并在舞台上开始调整大小。然而,它仍然不能在MAC的Firefox上工作。:(

在我的HTML代码中:

代码语言:javascript
复制
<link href="css/site.css" rel="stylesheet" type="text/css" />

代码语言:javascript
复制
 Test Site
代码语言:javascript
复制
<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>

我不想找到正确的方法来解决这个问题。下面是我当前的代码:

代码语言:javascript
复制
    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();
        }

    } 
EN

回答 1

Stack Overflow用户

发布于 2010-06-05 05:49:15

我使用一个ENTER_FRAME处理程序来侦听,直到stage.stageWidth > 0 && stage.stageHeight > 0

代码语言:javascript
复制
  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!
  }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2968036

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档