<?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>Steven Vachon</title> <atom:link href="/feed/" rel="self" type="application/rss+xml"/> <link>http://www.svachon.com</link> <description>Technology, web development, design and animation</description> <lastBuildDate>Thu, 29 Sep 2011 06:08:38 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=</generator> <item> <title>Single-File Facebook OAuth 2.0 Example</title> <link>http://www.svachon.com/blog/single-file-facebook-oauth-2-0-example/</link> <comments>http://www.svachon.com/blog/single-file-facebook-oauth-2-0-example/#comments</comments> <pubDate>Sun, 25 Sep 2011 18:41:53 +0000</pubDate> <dc:creator>Steven Vachon</dc:creator> <category><![CDATA[Websites]]></category> <category><![CDATA[Facebook]]></category> <category><![CDATA[Fix]]></category> <category><![CDATA[Optimization]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Security]]></category> <category><![CDATA[Tips]]></category> <category><![CDATA[Tricks]]></category> <guid isPermaLink="false">http://www.svachon.com/?p=333</guid> <description><![CDATA[I could never find a simple, straight-forward example of this stuff. Facebook&#8217;s documentation isn&#8217;t extremely clear either. Put this following code in an index.php file within your canvas URL&#8217;s root. Optionally, name the file session.php and include it in any &#8230; <a href="/blog/single-file-facebook-oauth-2-0-example/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I could never find a simple, straight-forward example of this stuff. Facebook&#8217;s documentation isn&#8217;t extremely clear either.<span id="more-333"></span></p> <p>Put this following code in an <em>index.php</em> file within your canvas <abbr title="Uniform Resource Locator">URL</abbr>&#8217;s root. Optionally, name the file <em>session.php</em> and <code>include</code> it in any files that need it.</p> <p><strong>Bug Notice:</strong></p> <p>When testing between two Facebook accounts, the user ID is not cleared. However, at this time, it appears to be an internal Facebook issue.</p> <div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/************
 * Facebook application auth
 *
 * Author:  Steven Vachon (http://www.svachon.com/)
 * Date Created:  September 25, 2011
 ************/</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'facebook-sdk/facebook.php'</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000088;">$app_id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'1234'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$app_secret</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'1234'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$app_page</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'https://apps.facebook.com/your-app-name/'</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000088;">$authorizing_page</span> <span style="color: #339933;">=</span> <span style="color: #990000;">parse_url</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$authorizing_page</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTPS'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'http://'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'https://'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_HOST'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$authorizing_page</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'path'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'?authorizing=true'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$code</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'code'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'code'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Connect to Facebook</span>
&nbsp;
	<span style="color: #000088;">$facebook</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Facebook<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'appId'</span>		<span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$app_id</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'secret'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$app_secret</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'token'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAccessToken</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'token'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	try
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Logged in and app is authorized</span>
		<span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">api</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/me'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Continues to any calling scripts</span>
	<span style="color: #009900;">&#125;</span>
	catch <span style="color: #009900;">&#40;</span>FacebookApiException <span style="color: #000088;">$error</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// CSRF protection</span>
		<span style="color: #000088;">$state</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">uniqid</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$login_url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLoginUrl</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'redirect_uri'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$authorizing_page</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'state'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$state</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Go to login and/or authorization request page</span>
		<span style="color: #000088;">$redirect</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;style type=&quot;text/css&quot;&gt;span{font-family:&quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size:11px; color:#333333} a{color:#3b5998; outline-style:none; text-decoration:none; font-weight:bold} a:hover{text-decoration:underline}&lt;/style&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$redirect</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;script type=&quot;text/javascript&quot;&gt; function lagMessage(){document.getElementById(&quot;message&quot;).innerHTML=&quot;Waiting for authorization&amp;hellip; &lt;a href=\&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$login_url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'\&quot; target=\&quot;_top\&quot;&gt;retry&lt;/a&gt;&quot;}'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$redirect</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'top.location.href=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$login_url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;; document.write(&quot;&lt;span id=\&quot;message\&quot;&gt;&lt;/span&gt;&quot;); setTimeout(&quot;lagMessage()&quot;,2000); &lt;/script&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$redirect</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Respond to authorization request</span>
	<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'https://graph.facebook.com/oauth/access_token?client_id='</span><span style="color: #339933;">.</span><span style="color: #000088;">$app_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;redirect_uri='</span><span style="color: #339933;">.</span><span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$authorizing_page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;client_secret='</span><span style="color: #339933;">.</span><span style="color: #000088;">$app_secret</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;code='</span><span style="color: #339933;">.</span><span style="color: #000088;">$code</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">parse_str</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'token'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'access_token'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Go back to app on facebook.com</span>
	<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$app_page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div> ]]></content:encoded> <wfw:commentRss>http://www.svachon.com/blog/single-file-facebook-oauth-2-0-example/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item> <title>Shuffle and Randomize Arrays in ActionScript and JavaScript</title> <link>http://www.svachon.com/blog/shuffle-and-randomize-arrays-in-actionscript-and-javascript/</link> <comments>http://www.svachon.com/blog/shuffle-and-randomize-arrays-in-actionscript-and-javascript/#comments</comments> <pubDate>Mon, 25 Jul 2011 00:04:45 +0000</pubDate> <dc:creator>Steven Vachon</dc:creator> <category><![CDATA[Websites]]></category> <category><![CDATA[ActionScript]]></category> <category><![CDATA[Adobe]]></category> <category><![CDATA[Browsers]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[Optimization]]></category> <category><![CDATA[Performance]]></category> <category><![CDATA[Tips]]></category> <category><![CDATA[Tricks]]></category> <guid isPermaLink="false">http://www.svachon.com/?p=315</guid> <description><![CDATA[I&#8217;d been looking around for the best solution for this and most of what I had found either performed poorly or wasn&#8217;t quite random enough. Not so strangely in the end, the best solution was the most basic. Note: This &#8230; <a href="/blog/shuffle-and-randomize-arrays-in-actionscript-and-javascript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I&#8217;d been looking around for the best solution for this and most of what I had found either performed poorly or wasn&#8217;t quite random enough. Not so strangely in the end, the best solution was the most basic.<span id="more-315"></span></p> <p>Note: This also works fine with the ActionScript 3 <code>Vector()</code> class.</p> <p>For ActionScript:</p> <div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> shuffleArray<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">array</span>:<span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> len:<span style="color: #0066CC;">int</span> = <span style="color: #0066CC;">array</span>.<span style="color: #0066CC;">length</span>;
&nbsp;
	<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>len; i++<span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> j:<span style="color: #0066CC;">int</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #66cc66;">&#40;</span>len-<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> value:<span style="color: #66cc66;">*</span> = <span style="color: #0066CC;">array</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
&nbsp;
		<span style="color: #0066CC;">array</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = <span style="color: #0066CC;">array</span><span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>;
		<span style="color: #0066CC;">array</span><span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span> = value;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">array</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div> <p>For JavaScript:</p> <div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> shuffleArray<span style="color: #009900;">&#40;</span>array<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> len <span style="color: #339933;">=</span> array.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>len<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> j <span style="color: #339933;">=</span> Math.<span style="color: #660066;">round</span><span style="color: #009900;">&#40;</span> Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>len<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> value <span style="color: #339933;">=</span> array<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		array<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> array<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		array<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> value<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">return</span> array<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div> ]]></content:encoded> <wfw:commentRss>http://www.svachon.com/blog/shuffle-and-randomize-arrays-in-actionscript-and-javascript/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item> <title>Absolute-to-Relative URLs</title> <link>http://www.svachon.com/blog/absolute-to-relative-urls/</link> <comments>http://www.svachon.com/blog/absolute-to-relative-urls/#comments</comments> <pubDate>Wed, 23 Mar 2011 07:42:43 +0000</pubDate> <dc:creator>Steven Vachon</dc:creator> <category><![CDATA[Projects]]></category> <category><![CDATA[Browsers]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[Optimization]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Plugins]]></category> <category><![CDATA[WordPress]]></category> <guid isPermaLink="false">http://www.svachon.com/wordpress/?p=49</guid> <description><![CDATA[While working on a WordPress-powered Flash application, I needed to populate a basepath with a relative URL. Hardcoding such would completely defeat the purpose of a CMS and since I couldn&#8217;t find anything on Google, I wrote this class. Before: &#8230; <a href="/blog/absolute-to-relative-urls/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>While working on a WordPress-powered Flash application, I needed to populate a basepath with a relative <abbr title="Uniform Resource Locator">URL</abbr>. Hardcoding such would completely defeat the purpose of a <abbr title="Content Management System">CMS</abbr> and since I couldn&#8217;t find anything on Google, I wrote this class.</p> <p><strong>Before:</strong> http://example.com/wp-content/themes/twentyten/style.css</p> <p><strong>After:</strong> /wp-content/themes/twentyten/style.css</p> <p><span id="more-49"></span></p> <ul> <li><a href="http://wordpress.org/extend/plugins/absolute-to-relative-urls/" rel="external">Download for WordPress</a></li> <li><a href="http://wordpress.org/extend/plugins/absolute-to-relative-urls/faq/" rel="external"><abbr title="Frequently Asked Questions">FAQ</abbr></a></li> </ul> <p>This isn&#8217;t just for WordPress, but will also work with any <abbr title="Hypertext Preprocessor">PHP</abbr> project:</p> <div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Absolute-to-Relative URLs 0.1 &lt;http://www.svachon.com/blog/absolute-to-relative-urls/&gt;
A class for use in shortening URL links.
*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Absolute_to_Relative_URLs
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$site_domain</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$site_url</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSiteURL</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> getDomainPath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$prefixes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://www.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'https://www.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'https://'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'www.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$prefixes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$separators</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'?'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'#'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$separatorIndex</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$separators</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$pos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pos</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pos</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$separatorIndex</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$separatorIndex</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$pos</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$domain</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$separatorIndex</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$path</span>   <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$separatorIndex</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$domain</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> getSiteURL<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">site_url</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTPS'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'http://'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'https://'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_HOST'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDomainPath</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">site_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">site_domain</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$path</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> relateURL<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Avoid unmatched protocols and already-relative URLs</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTPS'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'https://'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$url_split</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDomainPath</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url_split</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">site_domain</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url_split</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #000088;">$url_split</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'/'</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// Different domain, /, or unknown format</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> absolute_to_relative_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$absolute_to_relative_url_instance</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$absolute_to_relative_url_instance</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$absolute_to_relative_url_instance</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Absolute_to_Relative_URLs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$absolute_to_relative_url_instance</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">relateURL</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000088;">$absolute_to_relative_url_instance</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div> <p>And working with it is as simple as:</p> <div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> absolute_to_relative_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://your-domain.com/dir/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div> ]]></content:encoded> <wfw:commentRss>http://www.svachon.com/blog/absolute-to-relative-urls/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item> <title>iOS Alternate Theme for WordPress</title> <link>http://www.svachon.com/blog/ios-alternate-theme-for-wordpress/</link> <comments>http://www.svachon.com/blog/ios-alternate-theme-for-wordpress/#comments</comments> <pubDate>Fri, 18 Mar 2011 19:01:33 +0000</pubDate> <dc:creator>Steven Vachon</dc:creator> <category><![CDATA[Projects]]></category> <category><![CDATA[Adobe]]></category> <category><![CDATA[Apple]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[iOS]]></category> <category><![CDATA[iPad]]></category> <category><![CDATA[iPhone]]></category> <category><![CDATA[Mobile]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Plugins]]></category> <category><![CDATA[WordPress]]></category> <guid isPermaLink="false">http://www.svachon.com/wordpress/?p=47</guid> <description><![CDATA[Have your WordPress display a different theme to your Apple iOS (iPod/iPhone/iPad) users. This plugin becomes especially useful for WordPress-powered full-Flash websites. Since Apple has chosen to block Adobe Flash technology, your markets may require an HTML fallback. Download for &#8230; <a href="/blog/ios-alternate-theme-for-wordpress/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Have your WordPress display a different theme to your <a href="http://www.apple.com/ios/" rel="external">Apple iOS</a> (iPod/iPhone/iPad) users.<span id="more-47"></span></p> <p>This plugin becomes especially useful for WordPress-powered full-Flash websites. Since Apple has chosen to block Adobe Flash technology, your markets may require an <abbr title="HyperText Markup Language">HTML</abbr> fallback.</p> <ul> <li><a href="http://wordpress.org/extend/plugins/ios-alternate-theme/" rel="external">Download for WordPress</a></li> </ul>]]></content:encoded> <wfw:commentRss>http://www.svachon.com/blog/ios-alternate-theme-for-wordpress/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item> <title>Benchmark: ActionScript 3 Vector vs. getChildAt</title> <link>http://www.svachon.com/blog/benchmark-actionscript-3-vector-vs-getchildat/</link> <comments>http://www.svachon.com/blog/benchmark-actionscript-3-vector-vs-getchildat/#comments</comments> <pubDate>Fri, 11 Dec 2009 21:12:05 +0000</pubDate> <dc:creator>Steven Vachon</dc:creator> <category><![CDATA[Websites]]></category> <category><![CDATA[ActionScript]]></category> <category><![CDATA[Adobe]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[Optimization]]></category> <category><![CDATA[Performance]]></category> <category><![CDATA[Tips]]></category> <guid isPermaLink="false">http://www.svachon.com/wordpress/?p=45</guid> <description><![CDATA[I have never stored my particle instances in an array or any unique variables. There&#8217;s just no need to. The same can be achieved using only the child list, and with less bloat. New to Flash Player 10 is the &#8230; <a href="/blog/benchmark-actionscript-3-vector-vs-getchildat/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I have never stored my particle instances in an array or any unique variables. There&#8217;s just no need to. The same can be achieved using only the child list, and with less bloat. New to Flash Player 10 is the <code>Vector()</code> class, and while they <em>are</em> <a href="http://www.mikechambers.com/blog/2008/09/24/actioscript-3-vector-array-performance-comparison/">faster than arrays</a>, are they faster than <code>getChildAt()</code> and the child list? <span id="more-45"></span>While being faced with a new particle-based project, I figured I&#8217;d find out.</p> <p>Running the test on my MacBook Pro, the Vector is surprisingly only about 3% faster:</p> <p><strong>Vector</strong> 3036.02 ms</p> <p><strong>getChildAt</strong> 3122.12 ms</p> <p>2.76 %</p> <p>Here is the code:</p> <div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #66cc66;">*</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #66cc66;">*</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #66cc66;">*</span>;
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> VectorChild <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		protected <span style="color: #000000; font-weight: bold;">var</span> NUM_CHILDREN:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">20000</span>;
		protected <span style="color: #000000; font-weight: bold;">var</span> NUM_TESTS_EACH:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">100</span>;
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">var</span> containerTimes:Vector.<span style="color: #66cc66;">&lt;</span>int<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>int<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span>NUM_TESTS_EACH, NUM_CHILDREN<span style="color: #66cc66;">&#41;</span>;
		protected <span style="color: #000000; font-weight: bold;">var</span> testCount:<span style="color: #0066CC;">int</span> = -<span style="color: #cc66cc;">1</span>;
		protected <span style="color: #000000; font-weight: bold;">var</span> testPhase:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;	<span style="color: #808080; font-style: italic;">// 0=container, 1=vector</span>
		protected <span style="color: #000000; font-weight: bold;">var</span> timer:Timer = <span style="color: #000000; font-weight: bold;">new</span> Timer<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
		protected <span style="color: #000000; font-weight: bold;">var</span> vectorTimes:Vector.<span style="color: #66cc66;">&lt;</span>int<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>int<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span>NUM_TESTS_EACH, NUM_CHILDREN<span style="color: #66cc66;">&#41;</span>;
&nbsp;
&nbsp;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> VectorChild<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			startNextTest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> getAverages<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> containerSum:<span style="color: #0066CC;">int</span>;
			<span style="color: #000000; font-weight: bold;">var</span> vectorSum:<span style="color: #0066CC;">int</span>;
&nbsp;
			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>NUM_TESTS_EACH; i++<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				containerSum += containerTimes<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
				vectorSum += vectorTimes<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;===============================&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Average Container Test Time: &quot;</span>+ <span style="color: #66cc66;">&#40;</span>containerSum<span style="color: #66cc66;">/</span>NUM_TESTS_EACH<span style="color: #66cc66;">&#41;</span> +<span style="color: #ff0000;">&quot; ms&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Average Vector Test Time: &quot;</span>+ <span style="color: #66cc66;">&#40;</span>vectorSum<span style="color: #66cc66;">/</span>NUM_TESTS_EACH<span style="color: #66cc66;">&#41;</span> +<span style="color: #ff0000;">&quot; ms&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> handleContainerTest<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">time</span>:<span style="color: #0066CC;">int</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>NUM_CHILDREN; i++<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> sprite:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
				<span style="color: #808080; font-style: italic;">// Some nonsense</span>
				sprite.<span style="color: #006600;">x</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">200</span>;
				sprite.<span style="color: #006600;">y</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">150</span>;
&nbsp;
				addChild<span style="color: #66cc66;">&#40;</span>sprite<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>NUM_CHILDREN; i++<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				sprite = getChildAt<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span> as Sprite;
&nbsp;
				<span style="color: #808080; font-style: italic;">// More nonsense</span>
				sprite.<span style="color: #006600;">x</span> += <span style="color: #cc66cc;">50</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">time</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - <span style="color: #0066CC;">time</span>;
&nbsp;
			containerTimes<span style="color: #66cc66;">&#91;</span>testCount<span style="color: #66cc66;">&#93;</span> = <span style="color: #0066CC;">time</span>;
&nbsp;
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Container Test: &quot;</span>+ <span style="color: #0066CC;">time</span> +<span style="color: #ff0000;">&quot; ms&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			reset<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			startNextTest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> handleVectorTest<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">time</span>:<span style="color: #0066CC;">int</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> vector:Vector.<span style="color: #66cc66;">&lt;</span>Sprite<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Sprite<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span>NUM_CHILDREN<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>NUM_CHILDREN; i++<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> sprite:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
				<span style="color: #808080; font-style: italic;">// Some nonsense</span>
				sprite.<span style="color: #006600;">x</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">200</span>;
				sprite.<span style="color: #006600;">y</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">150</span>;
&nbsp;
				vector<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = sprite;
&nbsp;
				<span style="color: #808080; font-style: italic;">// Still gets added to the stage -- it needs to be visual, afterall</span>
				addChild<span style="color: #66cc66;">&#40;</span>sprite<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>NUM_CHILDREN; i++<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				sprite = vector<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
&nbsp;
				<span style="color: #808080; font-style: italic;">// More nonsense</span>
				sprite.<span style="color: #006600;">x</span> += <span style="color: #cc66cc;">50</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #0066CC;">time</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - <span style="color: #0066CC;">time</span>;
&nbsp;
			vectorTimes<span style="color: #66cc66;">&#91;</span>testCount<span style="color: #66cc66;">&#93;</span> = <span style="color: #0066CC;">time</span>;
&nbsp;
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Vector Test: &quot;</span>+ <span style="color: #0066CC;">time</span> +<span style="color: #ff0000;">&quot; ms&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			reset<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			startNextTest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> reset<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=NUM_CHILDREN-<span style="color: #cc66cc;">1</span>; i<span style="color: #66cc66;">&gt;</span>=<span style="color: #cc66cc;">0</span>; i--<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				removeChildAt<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> startNextTest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>++testCount <span style="color: #66cc66;">&gt;</span>= NUM_TESTS_EACH<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>testPhase == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					testCount = <span style="color: #cc66cc;">0</span>;
					testPhase = <span style="color: #cc66cc;">1</span>;
&nbsp;
					timer.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #006600;">TIMER_COMPLETE</span>, handleContainerTest<span style="color: #66cc66;">&#41;</span>;
&nbsp;
					timer.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #006600;">TIMER_COMPLETE</span>, handleVectorTest<span style="color: #66cc66;">&#41;</span>;
&nbsp;
					timer.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #66cc66;">&#125;</span>
				<span style="color: #b1b100;">else</span>
				<span style="color: #66cc66;">&#123;</span>
					getAverages<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #66cc66;">&#125;</span>
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>testCount == <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&amp;&amp;</span> testPhase == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				timer.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #006600;">TIMER_COMPLETE</span>, handleContainerTest<span style="color: #66cc66;">&#41;</span>;
&nbsp;
				timer.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #66cc66;">&#123;</span>
				timer.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div> <p>Keep in mind that it uses extra memory and adds an extra object to your code.</p>]]></content:encoded> <wfw:commentRss>http://www.svachon.com/blog/benchmark-actionscript-3-vector-vs-getchildat/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item> <title>WP-HTML-Compression</title> <link>http://www.svachon.com/blog/wp-html-compression/</link> <comments>http://www.svachon.com/blog/wp-html-compression/#comments</comments> <pubDate>Sun, 13 Sep 2009 00:07:57 +0000</pubDate> <dc:creator>Steven Vachon</dc:creator> <category><![CDATA[Projects]]></category> <category><![CDATA[Browsers]]></category> <category><![CDATA[Google]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[Optimization]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Plugins]]></category> <category><![CDATA[SEO]]></category> <category><![CDATA[WordPress]]></category> <guid isPermaLink="false">http://www.svachon.com/wordpress/?p=43</guid> <description><![CDATA[Combining HTML &#8220;minification&#8221; with cache and HTTP compression (WP Super Cache, or similar) will cut down your bandwidth and ensure near-immediate content delivery while increasing your Google page rank. This plugin will compress your HTML by removing standard comments and &#8230; <a href="/blog/wp-html-compression/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Combining <abbr title="HyperText Markup Language">HTML</abbr> &#8220;minification&#8221; with cache and <abbr title="HyperText Transfer Protocol">HTTP</abbr> compression (<a href="http://wordpress.org/extend/plugins/wp-super-cache/" rel="external"><abbr title="WordPress">WP</abbr> Super Cache</a>, or similar) will cut down your bandwidth and ensure near-immediate content delivery while increasing your Google page rank.</p> <p>This plugin will compress your <abbr title="HyperText Markup Language">HTML</abbr> by removing <strong>standard comments</strong> and <strong>white space</strong>; including new lines, carriage returns, tabs and excess spaces. Most importantly, by ignoring <code>&lt;pre&gt;</code>, <code>&lt;textarea&gt;</code>, <code>&lt;script&gt;</code> and Explorer conditional comment tags, <strong>presentation will not be affected</strong>. <span id="more-43"></span></p> <ul> <li><a href="http://wordpress.org/extend/plugins/wp-html-compression/" rel="external">Download for WordPress</a></li> <li><a href="http://wordpress.org/extend/plugins/wp-html-compression/faq/" rel="external"><abbr title="Frequently Asked Questions">FAQ</abbr></a></li> <li><a href="http://wordpress.org/extend/plugins/wp-html-compression/faq/" rel="external">Screenshots</a></li> </ul> <p>This isn&#8217;t just for WordPress, but will also work with any <abbr title="Hypertext Preprocessor">PHP</abbr> project:</p> <div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
WP-HTML-Compression 0.4 &lt;http://www.svachon.com/blog/wp-html-compression/&gt;
Reduce file size by safely removing all standard comments and unnecessary white space from an HTML document.
*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> WP_HTML_Compression
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Settings</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$compress_css</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$compress_js</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$info_comment</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$remove_comments</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Variables</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$html</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parseHTML</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __toString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">html</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> bottomComment<span style="color: #009900;">&#40;</span><span style="color: #000088;">$raw</span><span style="color: #339933;">,</span> <span style="color: #000088;">$compressed</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$raw</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$raw</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$compressed</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$compressed</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$savings</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$raw</span><span style="color: #339933;">-</span><span style="color: #000088;">$compressed</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$raw</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$savings</span> <span style="color: #339933;">=</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$savings</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;!--WP-HTML-Compression crunched this document by '</span><span style="color: #339933;">.</span><span style="color: #000088;">$savings</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'%. The file was '</span><span style="color: #339933;">.</span><span style="color: #000088;">$raw</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' bytes, but is now '</span><span style="color: #339933;">.</span><span style="color: #000088;">$compressed</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' bytes--&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> minifyHTML<span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/&lt;(?&lt;script&gt;script).*?&lt;\/script\s*&gt;|&lt;(?&lt;style&gt;style).*?&lt;\/style\s*&gt;|&lt;!(?&lt;comment&gt;--).*?--&gt;|&lt;(?&lt;tag&gt;[\/\w.:-]*)(?:&quot;.*?&quot;|\'.*?\'|[^\'&quot;&gt;]+)*&gt;|(?&lt;text&gt;((&lt;[^!\/\w.:-])?[^&lt;]*)+)|/si'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span> <span style="color: #000088;">$html</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">,</span> PREG_SET_ORDER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$overriding</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$raw_tag</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Variable reused for output</span>
		<span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$token</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$tag</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tag'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tag'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'script'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$strip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">compress_js</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'style'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$strip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">compress_css</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'&lt;!--wp-html-compression no compression--&gt;'</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$overriding</span> <span style="color: #339933;">=</span> <span style="color: #339933;">!</span><span style="color: #000088;">$overriding</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #666666; font-style: italic;">// Don't print the comment</span>
					<span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">remove_comments</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$overriding</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$raw_tag</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'textarea'</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #666666; font-style: italic;">// Remove any HTML comments, except MSIE conditional comments</span>
						<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&lt;!--(?!\s*(?:\[if [^\]]+]|&lt;!|&gt;))(?:(?!--&gt;).)*--&gt;/s'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tag</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'pre'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$tag</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'textarea'</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$raw_tag</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tag</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tag</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'/pre'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$tag</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'/textarea'</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$raw_tag</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">else</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$raw_tag</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$overriding</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$strip</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #b1b100;">else</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$strip</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
						<span style="color: #666666; font-style: italic;">// Remove any empty attributes, except:</span>
						<span style="color: #666666; font-style: italic;">// action, alt, content, src</span>
						<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/(\s+)(\w++(?&lt;!\baction|\balt|\bcontent|\bsrc)=&quot;&quot;)/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'$1'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
						<span style="color: #666666; font-style: italic;">// Remove any space before the end of self-closing XHTML tags</span>
						<span style="color: #666666; font-style: italic;">// JavaScript excluded</span>
						<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' /&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$strip</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">removeWhiteSpace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$html</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> parseHTML<span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">html</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">minifyHTML</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">info_comment</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bottomComment</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">html</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> removeWhiteSpace<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">stristr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'  '</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'  '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$str</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> wp_html_compression_finish<span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> WP_HTML_Compression<span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> wp_html_compression_start<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_html_compression_finish'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
wp_html_compression_start<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div> ]]></content:encoded> <wfw:commentRss>http://www.svachon.com/blog/wp-html-compression/feed/</wfw:commentRss> <slash:comments>10</slash:comments> </item> <item> <title>Folder Names with a Colon in Mac OS X</title> <link>http://www.svachon.com/blog/colon-folder-names-mac-osx/</link> <comments>http://www.svachon.com/blog/colon-folder-names-mac-osx/#comments</comments> <pubDate>Sat, 14 Mar 2009 15:10:23 +0000</pubDate> <dc:creator>Steven Vachon</dc:creator> <category><![CDATA[Miscellaneous]]></category> <category><![CDATA[Apple]]></category> <category><![CDATA[Mac]]></category> <category><![CDATA[Tips]]></category> <category><![CDATA[Tricks]]></category> <guid isPermaLink="false">http://www.svachon.com/wordpress/?p=40</guid> <description><![CDATA[When it comes to organizing a folder collection of any sort, the folder&#8217;s name plays a key role in finding your data in the future. One thing that&#8217;s always bothered me about folders with Windows and Mac was that they &#8230; <a href="/blog/colon-folder-names-mac-osx/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>When it comes to organizing a folder collection of any sort, the folder&#8217;s name plays a key role in finding your data in the future. One thing that&#8217;s always bothered me about folders with Windows and Mac was that they restricted me from using the colon character. Call me anal, but when you&#8217;re dealing with subtitle within subtitle, dashes take slightly longer to read. <span id="more-40"></span></p> <p>Both Windows and Mac use <em>normal width</em> colons to denote drive/directory heirarchy. For this reason, the character cannot be used in folder names. However, Mac allows the use of <em>full width</em> colons. Such can be found in the <a href="http://docs.info.apple.com/article.html?path=Mac/10.6/en/8164.html" rel="external">Character Palette</a> or by copying the character below:</p> <blockquote><p>：</p></blockquote> <p>Unfortunately, while still functioning, the same folder or character in Windows will display an undefined character.</p>]]></content:encoded> <wfw:commentRss>http://www.svachon.com/blog/colon-folder-names-mac-osx/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item> <title>Hello world!</title> <link>http://www.svachon.com/blog/hello-world/</link> <comments>http://www.svachon.com/blog/hello-world/#comments</comments> <pubDate>Fri, 14 Nov 2008 16:17:22 +0000</pubDate> <dc:creator>Steven Vachon</dc:creator> <category><![CDATA[Announcements]]></category> <guid isPermaLink="false">http://www.svachon.com/wordpress/?p=1</guid> <description><![CDATA[Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!]]></description> <content:encoded><![CDATA[<p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</p>]]></content:encoded> <wfw:commentRss>http://www.svachon.com/blog/hello-world/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item> <title>MX 2004: Garbage (A Big &#8220;Booo&#8221; for Macromedia)</title> <link>http://www.svachon.com/blog/mx-2004-is-garbage/</link> <comments>http://www.svachon.com/blog/mx-2004-is-garbage/#comments</comments> <pubDate>Sat, 13 Sep 2003 03:08:30 +0000</pubDate> <dc:creator>Steven Vachon</dc:creator> <category><![CDATA[Graphics]]></category> <category><![CDATA[Rants]]></category> <category><![CDATA[Websites]]></category> <category><![CDATA[ActionScript]]></category> <category><![CDATA[Adobe]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[Review]]></category> <category><![CDATA[Software]]></category> <guid isPermaLink="false">http://www.svachon.com/wordpress/?p=37</guid> <description><![CDATA[I was one of the many individuals really excited about the upcoming Flash version. I kept hearing about a few key features that I thought would be very useful. However, I expected more to be included in this version than &#8230; <a href="/blog/mx-2004-is-garbage/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I was one of the many individuals really excited about the upcoming Flash version. I kept hearing about a few key features that I thought would be very useful. However, I expected more to be included in this version than just those few features. Damn, was I wrong. Thank God I didn&#8217;t pre-order the software, or I&#8217;d be in the hole $300 for the upgrade. <span id="more-37"></span></p> <p>In this article I&#8217;ll start off with the few features that originally caught my eye and got me excited. Then I&#8217;ll go through the list of things that really upset me with Flash MX 2004 Professional. I&#8217;ll try not to rant (too much, heheh).</p> <h2 id="turn-ons"><a href="#turn-ons">What got me excited</a></h2> <h3 id="onmousewheel"><a href="#onmousewheel">onMouseWheel</a></h3> <p>Being a fan of JavaScript, the first thing that drew my attention to MX 2004 was its ability to support the mouse wheel without the need of an external script (<abbr title="Microsoft">MS</abbr> JScript). Avoiding browser scripting whenever possible is always a good thing, considering nearly 10,000,000 people on the Internet have it disabled. This feature still semi-pleases me, even after toying around with the software demo. However, I learned shortly thereafter that it&#8217;s a Windows-only feature. Boooo.</p> <h3 id="textfield-images"><a href="#textfield-images">TextField Images</a></h3> <p>Not only has this been a very popular question among rookies, but for quite some time I have wanted to create a &#8220;hack&#8221; class that would support images in text fields. But it seemed like such an annoying thing to write, so I never even started on it. Now, MX 2004 has support for such built in with no hacks used. I&#8217;ve tested it, and it seems to work okay. No complaints.</p> <h3 id="contextmenu"><a href="#contextmenu">ContextMenu</a></h3> <p>Something we&#8217;ve been wishing for since the days of Flash 3 &#8211; custom context menus. Even though it doesn&#8217;t remove the &#8220;About Flash Player&#8221; at the bottom, it still allows you to extend your web applications a little further. Good feature, and works fine.</p> <h2 id="turnoffs"><a href="#turnoffs">What turned me off</a></h2> <h3 id="ui-optimization"><a href="#ui-optimization"><abbr title="User Interface">UI</abbr> Optimization</a></h3> <p>There was a complete lack of optimization in the MX 2004 interface. First off, it looks nearly identical to that of Flash MX. That&#8217;s not so bad, though, since MX had a nice interface (in my opinion). All they noticeably added was some fluffy design (ie. the blue bars). But the main failing point is the <abbr title="Central Processing Unit">CPU</abbr> lag. I have a 3 <abbr title="Gigahertz">GHz</abbr> machine so there is no reason for a text editor to lag. But guess what? Macromedia managed to do it! If you&#8217;re running Windows 2000, try putting 500 or so lines of ActionScript (1 or 2, it makes no difference) in the Actions window then drag the scroll bar. They also removed &#8220;Actions&#8221; from the frame context menu. The History panel lags quite a bit too when going back around 10 steps.</p> <p>I decided not to even bother testing this software on any of my slower machines considering the results on my fastest.</p> <h3 id="timeline-effects"><a href="#timeline-effects">Timeline Effects</a></h3> <p>I hate to even mention the S-word, but Flash is not <a href="http://www.swishzone.com/">Swish</a>. At least it wasn&#8217;t before MX 2004. It was nice being able to say &#8220;I use Flash, not Swish&#8221; to people who think Flash movies are the easiest thing on the planet to create. Soon we&#8217;ll have thousands of timeline newbies calling themselves &#8220;Flash experts&#8221; instead of &#8220;Swish experts&#8221;. Swish introduced a wave of terrible Flash sites, and MX 2004 will bring on a new one. So, get ready.</p> <h3 id="fui-components"><a href="#fui-components">FUI Components</a></h3> <p>As if the MX components weren&#8217;t terrible enough, Macromedia had to recreate them to be even larger in file size. Meanwhile keeping many of the same bugs that were resident in the previous versions. If 55 <abbr title="Kilobyte">KB</abbr> for a combo box is small, I think I&#8217;m out of a job. On top of that, they include all these other components for practically anything you could think of. Is this good? I think not. It&#8217;s all &#8220;click here to be a professional&#8221; crap. That definately helps rookies replace me. Thanks Macromedia.</p> <h3 id="actionscript2"><a href="#actionscript2">ActionScript 2.0</a></h3> <p>I know the value of a good OOP language. But I also know when something new has no value. <abbr title="ActionScript 2">AS2</abbr> seems so pointless to me aside from Macromedia trying to put a stop to the &#8220;Flash bashing&#8221; from non-Flash programmers. Complaints of <abbr title="ActionScript 1">AS1</abbr> not being standardized enough must have really hurt Macromedia&#8217;s feelings. Enough so, that they put those programmers ahead of their current user base. They&#8217;d rather try to get new users than make their current ones happy. It must be corporate greed. They added so few features to MX 2004, so they keep advertising <abbr title="ActionScript 2">AS2</abbr>, which doesn&#8217;t offer us current Flash scripters anything new. Only a different syntax for writing things we&#8217;ve been doing for nearly 2 years. Extending classes with extends rather than prototypes is hardly a big leap. And their idea of typecasting is very primitive. <abbr title="ActionScript 2">AS2</abbr> is trying to be a programming language and it doesn&#8217;t even have binary variables! On top of that, because <abbr title="ActionScript 2">AS2</abbr> code is compiled, the file sizes are larger than code written in <abbr title="ActionScript 1">AS1</abbr>. Yeah, like we really needed that.</p> <h3 id="regex"><a href="#regex">Regular Expressions</a></h3> <p>We&#8217;ve been asking Macromedia for this since Flash 4, and they still fail to deliver. There are community written classes available, but due to ActionScript syntax, they aren&#8217;t perfect. They are around 10 <abbr title="Kilobyte">KB</abbr> in file size and aren&#8217;t extremely difficult to write. So, Macromedia has no excuse.</p> <h3 id="socket-security"><a href="#socket-security">Socket Security</a></h3> <p>Sockets with Flash are still very weak. We still cannot connect to other sites with a certificate. And since <abbr title="ActionScript 2">AS2</abbr> has no binary variables, we&#8217;re unable to reconstruct regular socket protocols. Boooo.</p> <h3 id="search-replace"><a href="#search-replace">RegExp Search &amp; Replace</a></h3> <p>Developers who use regular expressions for search &amp; replace are still required to use third party applications to get the job done comfortably. Boooo.</p> <h2>Conclusion</h2> <p>It seems to me that Flash MX 2004, both normal and Professional, are early alpha releases with &#8220;final&#8221; slapped on the front. They can&#8217;t be complete. They&#8217;re just too sloppy. Macromedia seems to be living by Microsoft&#8217;s philosophy on software development &#8211; &#8220;People don&#8217;t pay for bug fixes, they pay for new features&#8221;. Well, this new version of Flash has both few bug fixes and few new features. What&#8217;s even more unfortunate is that the majority of those new features are pointless and redundant. The 3 features that originally got me excited about MX 2004 aren&#8217;t enough to justify the amount of money required to use them. If you feel like wasting your money on this garbage, feel free. I&#8217;m not jumping on that sinking boat.</p>]]></content:encoded> <wfw:commentRss>http://www.svachon.com/blog/mx-2004-is-garbage/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item> <title>_global Across Remote ActionScript Timelines</title> <link>http://www.svachon.com/blog/_global-across-remote-actionscript-timelines/</link> <comments>http://www.svachon.com/blog/_global-across-remote-actionscript-timelines/#comments</comments> <pubDate>Mon, 01 Sep 2003 21:11:40 +0000</pubDate> <dc:creator>Steven Vachon</dc:creator> <category><![CDATA[Rants]]></category> <category><![CDATA[Websites]]></category> <category><![CDATA[ActionScript]]></category> <category><![CDATA[Adobe]]></category> <category><![CDATA[Bug]]></category> <category><![CDATA[Fix]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[Tips]]></category> <category><![CDATA[Tricks]]></category> <guid isPermaLink="false">http://www.svachon.com/wordpress/?p=33</guid> <description><![CDATA[Like many Flash developers, I like writing classes and optimizing bandwidth with remote libraries. ActionScript 1 uses prototypes to extend methods to a function object, and to be able to access that class globally, one would use _global. Unfortunately, global &#8230; <a href="/blog/_global-across-remote-actionscript-timelines/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Like many Flash developers, I like writing classes and optimizing bandwidth with remote libraries. ActionScript 1 uses prototypes to extend methods to a function object, and to be able to access that class globally, one would use <code>_global</code>. Unfortunately, global do not work as well as they&#8217;re explained to. This bug is resident in all minor versions of Flash Player 6, and still exists in Flash Player 7. <span id="more-33"></span></p> <p>Global variables, functions, objects and prototyped methods will work perfectly if only developing a single <abbr title="Small Web Format">SWF</abbr> site or application. Though, when developing with multiple <abbr title="Small Web Format">SWF</abbr> files, those procedures must be defined in a loaded timeline that is a child of or parent to the caller. Therefore, defining such in a <abbr title="Small Web Format">SWF</abbr> that is dynamically loaded into a MovieClip in <code>_root</code> will not be accessible to any MovieClip instantiated as a child or nested child of <code>_root</code>.</p> <p>Since the above paragraph is a lot to soak in, let&#8217;s create an example. In the root timeline, we&#8217;d have a manually created MovieClip with the instance name &#8220;mc1&#8243;, and on frame 1 [of the root timeline], we&#8217;d have the following code:</p> <div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">createEmptyMovieClip</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;mc2&quot;</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
mc2.<span style="color: #0066CC;">loadMovie</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;example.swf&quot;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div> <p>The structure would look like this:</p> <p><img src="/wordpress/wp-content/uploads/2003/09/example1.png" alt="Loaded SWF _global Example" width="423" height="222" class="size-full wp-image-166"/></p> <p>Here, you can see that <code>test_1</code> is invoked while <code>test_2</code> is not. The reason for this is because <code>test_1</code> is defined inside the main <abbr title="Small Web Format">SWF</abbr> and is set to global, meanwhile <code>test_2</code> is defined in a remote file and can only be called from within that timeline, any sibling and/or direct parent timeline even though it too has been declared as global. This is the bug that is still yet to be resolved by Macromedia.</p> <p>If you try to trace the <code>test_2</code> in Flash Player 6, it will return &#8220;Warning&#8221;. It has since been removed in version 7.</p> <h2>Workaround</h2> <p>There are ways to work around this, but it takes away from the neatness of your code. When delcaring, do so by pointing to the main <abbr title="Small Web Format">SWF</abbr>. Notice the use of <code>_level0</code> as opposed to <code>_root</code>. That way, whenever declaring and calling that variable, function or object, it may be done so from any timeline. Unfortunately, this doesn&#8217;t solve the same problem with methods added to predefined objects like MovieClip and String. Such methods would have to be defined in the main <abbr title="Small Web Format">SWF</abbr>.</p> <p><img src="/wordpress/wp-content/uploads/2003/09/example2.png" alt="Loaded SWF _global Workaround Example" width="423" height="163" class="size-full wp-image-169"/></p> <p>An example of creating a globally accessible class in <abbr title="ActionScript 1">AS1</abbr> from a loaded <abbr title="Small Web Format">SWF</abbr> would look as follows:</p> <div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">with</span> <span style="color: #66cc66;">&#40;</span>_level0<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">function</span> className<span style="color: #66cc66;">&#40;</span>msg<span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">this</span>.<span style="color: #006600;">msg</span> = msg;
		<span style="color: #0066CC;">this</span>.<span style="color: #006600;">init</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	className.<span style="color: #0066CC;">prototype</span>.<span style="color: #006600;">init</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>.<span style="color: #006600;">msg</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
classInstance = <span style="color: #000000; font-weight: bold;">new</span> _level0.<span style="color: #006600;">className</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;test&quot;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div> <p>Macromedia seems to have solved the problem for ActionScript 2 classes. An example of creating a globally accessible class in <abbr title="ActionScript 2">AS2</abbr> from a loaded <abbr title="Small Web Format">SWF</abbr> would look like any other class:</p> <div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> ClassName
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _msg:<span style="color: #0066CC;">String</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ClassName<span style="color: #66cc66;">&#40;</span>msg<span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		_msg = msg;
		init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>_msg<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> classInstance:ClassName = <span style="color: #000000; font-weight: bold;">new</span> ClassName<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;test&quot;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div> <p>As to why Macromedia would choose to fix the bug for <abbr title="ActionScript 2">AS2</abbr> and not <abbr title="ActionScript 1">AS1</abbr>, I can only assume that they just didn&#8217;t care. They are obviously trying to force everyone onto the new syntax. To keep file sizes down, I prefer to stick with MX and prototyped classes even though this bug can complicate things a little. I realize <abbr title="ActionScript 2">AS2</abbr> can be compiled into <abbr title="ActionScript 1">AS1</abbr> from MX 2004, but at this point, I wouldn&#8217;t trust Macromedia with that.</p>]]></content:encoded> <wfw:commentRss>http://www.svachon.com/blog/_global-across-remote-actionscript-timelines/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss> 
<!--WP-HTML-Compression saved 0.66%. Bytes before:113175, after:112433-->
