<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BIT Consultants &#187; Actionscript</title>
	<atom:link href="http://www.bitconsultants.net/tag/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bitconsultants.net</link>
	<description></description>
	<lastBuildDate>Sun, 25 Jul 2010 21:54:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Actionscript 2.0: Centered Popup Window</title>
		<link>http://www.bitconsultants.net/2009/actionscript-2-0-centered-popup-window/</link>
		<comments>http://www.bitconsultants.net/2009/actionscript-2-0-centered-popup-window/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 05:31:31 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.bitconsultants.net/?p=136</guid>
		<description><![CDATA[Centered popup for Actionscript 2.0]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<pre class="brush: jscript;">

function winOpen(url:String, winName:String, wide:Number, high:Number, chrome:Boolean, centered:Boolean)
{
//Chrome on window un-centered
if (chrome == true &amp;&amp; centered == false)­
{
getURL(&quot;javascript:&quot;+winName+&quot;=window.open('&quot;+url+&quot;', '&quot;+winName+&quot;', 'width=&quot;+wide+&quot;,height=&quot;+high+&quot;,left=0,top=0,toolbar=1,location=1,scrollbars=1,status=1,resizable=1,fullscreen=no'); &quot;+winName+&quot;.focus(); void(0);&quot;);
}
//Chromeless un-centered
else if (chrome == false &amp;&amp; centered == false)­
{
getURL(&quot;javascript:&quot;+winName+&quot;=window.open('&quot;+url+&quot;', '&quot;+winName+&quot;', 'width=&quot;+wide+&quot;,height=&quot;+high+&quot;'); &quot;+winName+&quot;.focus(); void(0);&quot;);
}
//Chrome on, centered
else if (chrome == true &amp;&amp; centered == true)
{
getURL(&quot;javascript:&quot;+winName+&quot;=window.open('&quot;+url+&quot;', '&quot;+winName+&quot;', 'width=&quot;+wide+&quot;,height=&quot;+high+&quot;,left=0,top=0,toolbar=1,location=1,scrollbars=1,status=1,resizable=1,fullscreen=no'); &quot;+winName+&quot;.focus(); screen_height = window.screen.availHeight;screen_width = window.screen.availWidth; left_point = parseInt(screen_width/2)-(&quot;+wide+&quot;/2); top_point = parseInt(screen_height/2)-(&quot;+high+&quot;/2); setTimeout('&quot;+winName+&quot;.moveTo(left_point,top_point)',10); void(0);&quot;);
}
//Chromeless, centered (most popular!)
else if (chrome == false &amp;&amp; centered == true)
{
getURL(&quot;javascript:&quot;+winName+&quot;=window.open('&quot;+url+&quot;', '&quot;+winName+&quot;', 'width=&quot;+wide+&quot;,height=&quot;+high+&quot;,left=0,top=0,toolbar=no,location=no,scrollbars=no,status=no,resizable=no,fullscreen=no'); &quot;+winName+&quot;.focus(); screen_height = window.screen.availHeight;screen_width = window.screen.availWidth; left_point = parseInt(screen_width/2)-(&quot;+wide+&quot;/2); top_point = parseInt(screen_height/2)-(&quot;+high+&quot;/2); setTimeout('&quot;+winName+&quot;.moveTo(left_point,top_point)',10); void(0);&quot;);
}
}

//Sample of application, requires a button with instance name of button_mc on stage
button_mc.onRelease = function()
{
winOpen(&quot;http://www.bitconsultants.net/&quot;, &quot;MyWindow&quot;, 350, 350, true, true);
­}
</pre>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">
<pre class="geshifilter-actionscript"><span style="color: #000000; font-weight: bold;">function</span> winOpen<span style="color: #66cc66;">(</span><span style="color: #0066cc;">url</span>:<span style="color: #0066cc;">String</span>, winName:<span style="color: #0066cc;">String</span>, wide:<span style="color: #0066cc;">Number</span>, high:<span style="color: #0066cc;">Number</span>, chrome:<span style="color: #0066cc;">Boolean</span>, centered:<span style="color: #0066cc;">Boolean</span><span style="color: #66cc66;">)</span>
<span style="color: #66cc66;">{</span>
    <span style="color: #808080; font-style: italic;">//Chrome on window un-centered</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>chrome == <span style="color: #000000; font-weight: bold;">true</span> &amp;&amp; centered == <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">)</span>­
    <span style="color: #66cc66;">{</span>
        <span style="color: #0066cc;">getURL</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"javascript:"</span>+winName+<span style="color: #ff0000;">"=window.open('"</span>+<span style="color: #0066cc;">url</span>+<span style="color: #ff0000;">"', '"</span>+winName+<span style="color: #ff0000;">"', 'width="</span>+wide+<span style="color: #ff0000;">",height="</span>+high+<span style="color: #ff0000;">",left=0,top=0,toolbar=1,location=1,scrollbars=1,status=1,resizable=1,fullscreen=no'); "</span>+winName+<span style="color: #ff0000;">".focus(); void(0);"</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>
    <span style="color: #808080; font-style: italic;">//Chromeless un-centered</span>
    <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>chrome == <span style="color: #000000; font-weight: bold;">false</span> &amp;&amp; centered == <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">)</span>­
    <span style="color: #66cc66;">{</span>
        <span style="color: #0066cc;">getURL</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"javascript:"</span>+winName+<span style="color: #ff0000;">"=window.open('"</span>+<span style="color: #0066cc;">url</span>+<span style="color: #ff0000;">"', '"</span>+winName+<span style="color: #ff0000;">"', 'width="</span>+wide+<span style="color: #ff0000;">",height="</span>+high+<span style="color: #ff0000;">"'); "</span>+winName+<span style="color: #ff0000;">".focus(); void(0);"</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>
    <span style="color: #808080; font-style: italic;">//Chrome on, centered</span>
    <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>chrome == <span style="color: #000000; font-weight: bold;">true</span> &amp;&amp; centered == <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">)</span>
    <span style="color: #66cc66;">{</span>
        <span style="color: #0066cc;">getURL</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"javascript:"</span>+winName+<span style="color: #ff0000;">"=window.open('"</span>+<span style="color: #0066cc;">url</span>+<span style="color: #ff0000;">"', '"</span>+winName+<span style="color: #ff0000;">"', 'width="</span>+wide+<span style="color: #ff0000;">",height="</span>+high+<span style="color: #ff0000;">",left=0,top=0,toolbar=1,location=1,scrollbars=1,status=1,resizable=1,fullscreen=no'); "</span>+winName+<span style="color: #ff0000;">".focus(); screen_height = window.screen.availHeight;screen_width = window.screen.availWidth; left_point = parseInt(screen_width/2)-("</span>+wide+<span style="color: #ff0000;">"/2); top_point = parseInt(screen_height/2)-("</span>+high+<span style="color: #ff0000;">"/2); setTimeout('"</span>+winName+<span style="color: #ff0000;">".moveTo(left_point,top_point)',10); void(0);"</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>
    <span style="color: #808080; font-style: italic;">//Chromeless, centered (most popular!)</span>
    <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>chrome == <span style="color: #000000; font-weight: bold;">false</span> &amp;&amp; centered == <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">)</span>
    <span style="color: #66cc66;">{</span>
        <span style="color: #0066cc;">getURL</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"javascript:"</span>+winName+<span style="color: #ff0000;">"=window.open('"</span>+<span style="color: #0066cc;">url</span>+<span style="color: #ff0000;">"', '"</span>+winName+<span style="color: #ff0000;">"', 'width="</span>+wide+<span style="color: #ff0000;">",height="</span>+high+<span style="color: #ff0000;">",left=0,top=0,toolbar=no,location=no,scrollbars=no,status=no,resizable=no,fullscreen=no'); "</span>+winName+<span style="color: #ff0000;">".focus(); screen_height = window.screen.availHeight;screen_width = window.screen.availWidth; left_point = parseInt(screen_width/2)-("</span>+wide+<span style="color: #ff0000;">"/2); top_point = parseInt(screen_height/2)-("</span>+high+<span style="color: #ff0000;">"/2); setTimeout('"</span>+winName+<span style="color: #ff0000;">".moveTo(left_point,top_point)',10); void(0);"</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>
<span style="color: #66cc66;">}</span>

<span style="color: #808080; font-style: italic;">//Sample of application, requires a button with instance name of button_mc on stage</span>
button_mc.<span style="color: #0066cc;">onRelease</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>
<span style="color: #66cc66;">{</span>
    winOpen<span style="color: #66cc66;">(</span><span style="color: #ff0000;">"http://www.bitconsultants.net/"</span>, <span style="color: #ff0000;">"MyWindow"</span>, <span style="color: #cc66cc;">350</span>, <span style="color: #cc66cc;">350</span>, <span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">)</span>;
­<span style="color: #66cc66;">}</span></pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bitconsultants.net/2009/actionscript-2-0-centered-popup-window/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
