A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] Centre MC with Browser Zoom

  1. #1
    Member
    Join Date
    Apr 2001
    Location
    Cape Town
    Posts
    99

    resolved [RESOLVED] Centre MC with Browser Zoom

    I have been struggling with the affect the browser zoom level has on my application for days. Finally I built the below test swf and noticed that when user zoom in using the browser zoom (IE 8) the box centering stopped working correctly. Any suggestions?

    Movie with moviclip named box and button named mybtn with three text fields:

    mybtn.addEventListener(MouseEvent.CLICK,centrebox) ;
    function centrebox(e:MouseEvent):void {
    box.x=stage.stageWidth/2;
    box.y=stage.stageHeight/2;
    mytext1.text="Stage width: "+String(stage.stageWidth)
    mytext2.text="Stage width / 2: "+String(stage.stageWidth/2)
    mytext3.text="Box x position: "+String(box.x)
    }

  2. #2
    Member
    Join Date
    Apr 2001
    Location
    Cape Town
    Posts
    99
    I have foundthe problem by creating a Event to track the mouseX. The sollution is simple to create a variable to capture the initial stage width and use that for the x and y positioning. Do not update the stage width every time the button is pressed:

    var xposition:uint=stage.stageWidth;
    var yposition:uint=stage.stageHeight;
    mybtn.addEventListener(MouseEvent.CLICK,centrebox) ;
    function centrebox(e:MouseEvent):void {
    box.x=xposition/2;
    box.y=yposition/2;
    mytext1.text="Stage width: "+String(stage.stageWidth);
    mytext2.text="Stage width / 2: "+String(stage.stageWidth/2);
    mytext3.text="Box x position: "+String(box.x);
    }
    stage.addEventListener(Event.ENTER_FRAME,tackMouse );
    function tackMouse(e:Event):void {
    mytext3.text=String(mouseX);
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center