Use the screen resolution values to center a pop-up browser window
package{
import flash.display.Sprite;
import flash.system.Capabilities;
import flash.net.*;
public class Main extends Sprite{
public function Main(){
var resX:int = flash.system.Capabilities.screenResolutionX;
var resY:int = flash.system.Capabilities.screenResolutionY;
var winW:int = 200;
var winH:int = 200;
var winX:int = (resX / 2) - (winW / 2);
var winY:int = (resY / 2) - (winH / 2);
var jsCode:String = "javascript:void(newWin=window.open('http://www.java2s.com/'," +
"'newWindow', 'width=" + winW +
", height=" + winH + "," +
"left=" + winX + ",top=" + winY + "'));";
}
}
}
Related examples in the same category