A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] Reset stage after broser zoom levels changed

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

    resolved [RESOLVED] Reset stage after broser zoom levels changed

    I am trying to reset the stage width to its orriginal size when user click on button after changes to the browser zoom level.

    However this is restting the width of stage according to the new zoom level with the result that the stage size increase even more. I tried using a variable to use as holder of orriginal stageWidth but how to reset it to that width?

    stage.align = StageAlign.TOP_LEFT;
    stage.scaleMode = StageScaleMode.NO_SCALE;
    var mystageW:uint=stage.stageWidth;

    mybtn.addEventListener(MouseEvent.CLICK,update);

    function update(e:MouseEvent):void {

    var zoom:uint=stage.stageWidth-mystageW;

    if (stage.stageWidth!=mystageW) {

    ExternalInterface.call("function( id, w ) { document.getElementById(id).style.width = w + 'px'; }", ExternalInterface.objectID, stage.stageWidth );

    }
    }
    Last edited by eye4see; 07-05-2011 at 07:44 AM.

  2. #2
    Member
    Join Date
    Apr 2001
    Location
    Cape Town
    Posts
    99
    By the look of the number of views it seems like a lot of people have a problem with this. After a few days of struggle I came to this conclusion.

    There is no way to controll the Browser zoom level. You can however detect when the stage.stageWidth has changed and then call a javascript funtion to reset the stage. Another option is:
    stage.scaleMode = StageScaleMode.NO_SCALE;

    But I found the best sollution is to simply go with the flow and allow for scaling. I had some trouble with this as I position the objects every time using stage.stageWidth. Now even though when you track stage.stageWidth it will update every time you zoom in or out, never use the stage.stageWidth option on a button to position. Strange as it may seem the initial stage.stageWidth must be used. Therefore I created a variable to hold this value. But to make it just a bit more complex when I use stage.stageWidth to populate the variable I was forced to start the application in a window with 100% zoom. So this forced me to rather hardcode the variable according to the size of my swf. This way I am certain that at whatever zoom level the window is set, the value will stay the same.

    Hope this makes some sense and are helpfull to others.

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