At some point we all need a centered popup windows. Here is a useful Actionscript 2.0 function to help get a popup window, that allows for some customization based on input parameters. Check the actual implementation at the bottom. It is also worth mentioning here, that no AS popup script will work in local testing mode. You must upload to a server (or move to a local server directory) for this to function properly.
function winOpen(url:String, winName:String, wide:Number, high:Number, chrome:Boolean, centered:Boolean)
{
//Chrome on window un-centered
if (chrome == true && centered == false)
{
getURL("javascript:"+winName+"=window.open('"+url+"', '"+winName+"', 'width="+wide+",height="+high+",left=0,top=0,toolbar=1,location=1,scrollbars=1,status=1,resizable=1,fullscreen=no'); "+winName+".focus(); void(0);");
}
//Chromeless un-centered
else if (chrome == false && centered == false)
{
getURL("javascript:"+winName+"=window.open('"+url+"', '"+winName+"', 'width="+wide+",height="+high+"'); "+winName+".focus(); void(0);");
}
//Chrome on, centered
else if (chrome == true && centered == true)
{
getURL("javascript:"+winName+"=window.open('"+url+"', '"+winName+"', 'width="+wide+",height="+high+",left=0,top=0,toolbar=1,location=1,scrollbars=1,status=1,resizable=1,fullscreen=no'); "+winName+".focus(); screen_height = window.screen.availHeight;screen_width = window.screen.availWidth; left_point = parseInt(screen_width/2)-("+wide+"/2); top_point = parseInt(screen_height/2)-("+high+"/2); setTimeout('"+winName+".moveTo(left_point,top_point)',10); void(0);");
}
//Chromeless, centered (most popular!)
else if (chrome == false && centered == true)
{
getURL("javascript:"+winName+"=window.open('"+url+"', '"+winName+"', 'width="+wide+",height="+high+",left=0,top=0,toolbar=no,location=no,scrollbars=no,status=no,resizable=no,fullscreen=no'); "+winName+".focus(); screen_height = window.screen.availHeight;screen_width = window.screen.availWidth; left_point = parseInt(screen_width/2)-("+wide+"/2); top_point = parseInt(screen_height/2)-("+high+"/2); setTimeout('"+winName+".moveTo(left_point,top_point)',10); void(0);");
}
}
//Sample of application, requires a button with instance name of button_mc on stage
button_mc.onRelease = function()
{
winOpen("http://www.bitconsultants.net/", "MyWindow", 350, 350, true, true);
}
function winOpen(url:String, winName:String, wide:Number, high:Number, chrome:Boolean, centered:Boolean) { //Chrome on window un-centered if (chrome == true && centered == false) { getURL("javascript:"+winName+"=window.open('"+url+"', '"+winName+"', 'width="+wide+",height="+high+",left=0,top=0,toolbar=1,location=1,scrollbars=1,status=1,resizable=1,fullscreen=no'); "+winName+".focus(); void(0);"); } //Chromeless un-centered else if (chrome == false && centered == false) { getURL("javascript:"+winName+"=window.open('"+url+"', '"+winName+"', 'width="+wide+",height="+high+"'); "+winName+".focus(); void(0);"); } //Chrome on, centered else if (chrome == true && centered == true) { getURL("javascript:"+winName+"=window.open('"+url+"', '"+winName+"', 'width="+wide+",height="+high+",left=0,top=0,toolbar=1,location=1,scrollbars=1,status=1,resizable=1,fullscreen=no'); "+winName+".focus(); screen_height = window.screen.availHeight;screen_width = window.screen.availWidth; left_point = parseInt(screen_width/2)-("+wide+"/2); top_point = parseInt(screen_height/2)-("+high+"/2); setTimeout('"+winName+".moveTo(left_point,top_point)',10); void(0);"); } //Chromeless, centered (most popular!) else if (chrome == false && centered == true) { getURL("javascript:"+winName+"=window.open('"+url+"', '"+winName+"', 'width="+wide+",height="+high+",left=0,top=0,toolbar=no,location=no,scrollbars=no,status=no,resizable=no,fullscreen=no'); "+winName+".focus(); screen_height = window.screen.availHeight;screen_width = window.screen.availWidth; left_point = parseInt(screen_width/2)-("+wide+"/2); top_point = parseInt(screen_height/2)-("+high+"/2); setTimeout('"+winName+".moveTo(left_point,top_point)',10); void(0);"); } } //Sample of application, requires a button with instance name of button_mc on stage button_mc.onRelease = function() { winOpen("http://www.bitconsultants.net/", "MyWindow", 350, 350, true, true); }

Thanks.. I use this script and its working correctly…
Thanks again
==========================================
cisco braindumps the world wide market for networking equipments.
Hi Donald, glad it’s working for you.
hi there, I have been testing this code and I can seem to get it to work. I am using a scroll panel with the buttons in it. I am calling the buttons from the main movie with _root. I placed the actual function code into the movie panel and the actual code to call the desired link in the parent movie with the button script. To no avail though… not sure if I’m missing something here. Thanks