<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Mike Morearty]]></title>
  <link href="http://www.morearty.com/blog/feed/" rel="self"/>
  <link href="http://www.morearty.com/blog/"/>
  <updated>2013-06-06T15:39:53-07:00</updated>
  <id>http://www.morearty.com/blog/</id>
  <author>
    <name><![CDATA[Mike Morearty]]></name>
    
  </author>

  
    <entry>
    <title type="html"><![CDATA[HTML+CSS to make an image "bounce" to a larger size on hover]]></title>
    <link href="http://www.morearty.com/blog/2013/06/06/html-css-to-make-an-image-bounce-to-a-larger-size-on-hover/"/>
    <updated>2013-06-06T00:00:00-07:00</updated>
    <id>http://www.morearty.com/blog/2013/06/06/html-css-to-make-an-image-bounce-to-a-larger-size-on-hover</id>
    <content type="html"><![CDATA[<style type="text/css">
    .star {
        background-image: url(http://www.morearty.com/blog/assets/2013/06/star.gif);
        background-size: 15px;
        background-repeat: no-repeat;
        background-position: center;
        background-clip: border-box;
        transition: background-size 0.2s; /* important: Safari needs -webkit prefix */
        transition-timing-function: cubic-bezier(.07,1.41,.82,1.41);
        display: inline-block;
        width: 20px;
        height: 30px;
        text-decoration: none;
        cursor: pointer;
    }
    .star:hover {
        background-size: 20px;
    }
</style>

<script src="http://lea.verou.me/prefixfree/prefixfree.min.js" type="text/javascript"></script>

<p>Okay, in your HTML, you have an image, and you want to make it do a little animated &ldquo;bounce&rdquo; to a slightly larger size when the mouse hovers over it:</p>

<p><a class="star"></a><a class="star"></a><a class="star"></a><a class="star"></a><a class="star"></a></p>

<p>Here is the code to do that.</p>

<p>First, the HTML for five yellow stars in a row.  As you can see, these are just empty anchor tags with a CSS class of <code>star</code>.</p>
<div class="highlight"><pre><code class="html language-html" data-lang="html"><span class="nt">&lt;a</span> <span class="na">class=</span><span class="s">&quot;star&quot;</span><span class="nt">&gt;&lt;/a&gt;&lt;a</span> <span class="na">class=</span><span class="s">&quot;star&quot;</span><span class="nt">&gt;&lt;/a&gt;&lt;a</span> <span class="na">class=</span><span class="s">&quot;star&quot;</span><span class="nt">&gt;&lt;/a&gt;&lt;a</span> <span class="na">class=</span><span class="s">&quot;star&quot;</span><span class="nt">&gt;&lt;/a&gt;&lt;a</span>
<span class="na">class=</span><span class="s">&quot;star&quot;</span><span class="nt">&gt;&lt;/a&gt;</span>
</code></pre></div>
<p>Then, the CSS.  The important thing is that we put the image in the <em>background</em> of the element (using CSS&rsquo;s <code>background-image</code>).  That way, when the background image changes size, it will not change the size of the element itself, and thus it will not cause the surrounding HTML to have to re-flow.  The image is centered on the background of the element, and we are hard-coding its size to <code>15px</code>:</p>
<div class="highlight"><pre><code class="css language-css" data-lang="css"><span class="nc">.star</span> <span class="p">{</span>
    <span class="k">background-image</span><span class="o">:</span> <span class="sx">url(star.gif)</span><span class="p">;</span>
    <span class="k">background</span><span class="o">-</span><span class="k">size</span><span class="o">:</span> <span class="m">15px</span><span class="p">;</span>
    <span class="k">background-repeat</span><span class="o">:</span> <span class="k">no-repeat</span><span class="p">;</span>
    <span class="k">background-position</span><span class="o">:</span> <span class="k">center</span><span class="p">;</span>
</code></pre></div>
<p>For good measure, we&rsquo;ll also set <code>background-clip</code> property to be as big as possible, thus reducing the likelihood that, after growing, the background image might be clipped:</p>
<div class="highlight"><pre><code class="css language-css" data-lang="css">    <span class="nt">background-clip</span><span class="o">:</span> <span class="nt">border-box</span><span class="o">;</span>
</code></pre></div>
<p>Now let&rsquo;s specify that whenever the <code>background-size</code> changes, we will <em>animate</em> the transition to the new size:</p>
<div class="highlight"><pre><code class="css language-css" data-lang="css">    <span class="nt">transition</span><span class="o">:</span> <span class="nt">background-size</span> <span class="nt">0</span><span class="nc">.2s</span><span class="o">;</span>
</code></pre></div>
<p>(Note, Safari will need <code>-webkit-transition</code>.  Or just use Lea Verou&rsquo;s <a href="http://leaverou.github.io/prefixfree/">-prefix-free</a> script to avoid having to worry about prefixes.)</p>

<p>Now let&rsquo;s make it bounce:</p>
<div class="highlight"><pre><code class="css language-css" data-lang="css">    <span class="nt">transition-timing-function</span><span class="o">:</span> <span class="nt">cubic-bezier</span><span class="o">(</span><span class="nc">.07</span><span class="o">,</span><span class="nt">1</span><span class="nc">.41</span><span class="o">,</span><span class="nc">.82</span><span class="o">,</span><span class="nt">1</span><span class="nc">.41</span><span class="o">);</span>
</code></pre></div>
<p>As for the numbers I am passing to cubic-bezier: I just played around with <a href="http://cubic-bezier.com/#.07,1.41,.82,1.41">cubic-bezier.com</a> until I found numbers I liked.  (That site is also by Lea Verou. She is amazing.)  If you like the animation but don&rsquo;t want the bounce, just omit line <code>transition-timing-function</code> line.</p>

<p>Some extra CSS junk, and then close our tag:</p>
<div class="highlight"><pre><code class="css language-css" data-lang="css">    <span class="nt">display</span><span class="o">:</span> <span class="nt">inline-block</span><span class="o">;</span>
    <span class="nt">width</span><span class="o">:</span> <span class="nt">20px</span><span class="o">;</span>
    <span class="nt">height</span><span class="o">:</span> <span class="nt">30px</span><span class="o">;</span>
    <span class="nt">text-decoration</span><span class="o">:</span> <span class="nt">none</span><span class="o">;</span>
    <span class="nt">cursor</span><span class="o">:</span> <span class="nt">pointer</span><span class="o">;</span>
<span class="err">}</span>
</code></pre></div>
<p>Finally, specify that when the user hovers over a star, the <code>background-size</code> should grow from 15 to 20:</p>
<div class="highlight"><pre><code class="css language-css" data-lang="css"><span class="nc">.star</span><span class="nd">:hover</span> <span class="p">{</span>
    <span class="k">background</span><span class="o">-</span><span class="k">size</span><span class="o">:</span> <span class="m">20px</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div>
<p>That&rsquo;s it.  You can see all the necessary code, and experiment with it, <a href="http://jsfiddle.net/R2UkY/">here</a>.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[The hacker's way to install Apache, PHP, MySQL, and/or WordPress on OS X Mountain Lion]]></title>
    <link href="http://www.morearty.com/blog/2013/02/03/the-hackers-way-to-install-apache-php-mysql-and-or-wordpress-on-osx-mountain-lion/"/>
    <updated>2013-02-03T13:35:04-08:00</updated>
    <id>http://www.morearty.com/blog/2013/02/03/the-hackers-way-to-install-apache-php-mysql-and-or-wordpress-on-osx-mountain-lion</id>
    <content type="html"><![CDATA[<p>By &ldquo;the hacker&rsquo;s way,&rdquo; I mean that these instructions are for people who:</p>

<ol>
<li>prefer using the command line; and</li>
<li>want to understand what&rsquo;s going on, so they can undo or fix things later if
necessary.</li>
</ol>

<p>You can follow the below instructions without installing all four software
packages.  For example, you can install Apache+PHP+MySQL without installing
WordPress, and so on.</p>

<p>Wherever I mention &ldquo;vim&rdquo; below, if you aren&rsquo;t familiar with vim, you can
obviously substitute any other editor you want.  &ldquo;nano&rdquo; is probably the
easiest one.</p>

<h2>To install Apache</h2>

<p>Apache is already installed in Mountain Lion; it just needs to be enabled.  Do
this:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash">sudo vim /etc/apache2/users/<span class="sb">`</span>whoami<span class="sb">`</span>.conf
</code></pre></div>
<p>Put this in that file (change <code>USERNAME</code>):</p>
<div class="highlight"><pre><code class="apache language-apache" data-lang="apache"><span class="nt">&lt;Directory</span> <span class="s">&quot;/Users/USERNAME/Sites/&quot;</span><span class="nt">&gt;</span>
  <span class="nb">Options</span> Indexes MultiViews
  <span class="nb">AllowOverride</span> <span class="k">All</span>
  <span class="nb">Order</span> allow,deny
  <span class="nb">Allow</span> from <span class="k">all</span>
<span class="nt">&lt;/Directory&gt;</span>
</code></pre></div>
<p>Create the <code>~/Sites</code> directory, which will be Apache&rsquo;s root directory for
<code>http://localhost/~USERNAME</code>:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash">mkdir ~/Sites
</code></pre></div>
<p>If you want Apache to launch automatically after every reboot:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash">sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

<span class="c"># To prevent it from auto-loading after future reboots:</span>
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

<span class="c"># To stop or restart it for now, without changing future reboot behavior:</span>
sudo launchctl unload -F /System/Library/LaunchDaemons/org.apache.httpd.plist
sudo launchctl load -F /System/Library/LaunchDaemons/org.apache.httpd.plist
</code></pre></div>
<p>If you only want to start Apache now, and require manual launch after every
reboot:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash">sudo apachectl start

<span class="c"># If you need to restart or stop it later:</span>
sudo apachectl restart
sudo apachectl stop
</code></pre></div>
<p>Try it out:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash"><span class="nb">echo</span> <span class="s1">&#39;This is ~/Sites/index.html&#39;</span> &gt; ~/Sites/index.html
open http://localhost/~<span class="sb">`</span>whoami<span class="sb">`</span>
</code></pre></div>
<p>If you need to make any configuration changes to Apache, the config file is
<code>/etc/apache2/httpd.conf</code>.</p>

<h2>To install php</h2>

<p>PHP is already installed; it just needs to be enabled.  Do this:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash">sudo vim /etc/apache2/httpd.conf
</code></pre></div>
<p>Find the line that says this:</p>
<div class="highlight"><pre><code class="apache language-apache" data-lang="apache"><span class="c">#LoadModule php5_module libexec/apache2/libphp5.so</span>
</code></pre></div>
<p>Remove the leading <code>#</code> comment character and then save the file.</p>

<p>By default, php code does not support the shorter <code>&lt;? ... ?&gt;</code> tags, but instead
requires the more verbose <code>&lt;?php ... ?&gt;</code> tags.  If you want to enable the
shorter tags:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash">sudo vim /private/etc/php.ini
</code></pre></div>
<p>And change <code>short_open_tag = Off</code> to <code>short_open_tag = On</code>.</p>

<p>Then restart Apache, as described above:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash"><span class="c"># if you installed Apache to launch automatically on reboot:</span>
sudo launchctl unload -F /System/Library/LaunchDaemons/org.apache.httpd.plist
sudo launchctl load -F /System/Library/LaunchDaemons/org.apache.httpd.plist

<span class="c"># otherwise:</span>
sudo apachectl restart
</code></pre></div>
<p>Test it out:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash"><span class="nb">echo</span> <span class="s1">&#39;&lt;?php phpinfo() ?&gt;&#39;</span> &gt; ~/Sites/phptest.php
open <span class="s2">&quot;http://localhost/~`whoami`/phptest.php&quot;</span>
</code></pre></div>
<p>If you need to modify PHP&rsquo;s configuration, its main config file is
<code>/private/etc/php.ini</code>.  (The output of the <code>phpinfo()</code> call in the above
phptest.php file also tells you that.)</p>

<h2>To install MySQL</h2>

<p>If you don&rsquo;t already have <a href="http://mxcl.github.com/homebrew/">Homebrew</a>,
install it.  Then:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash">brew install mysql
</code></pre></div>
<p>As per the instructions that were displayed by <code>brew install mysql</code>, set up
databases to run <em>as your user account</em> with:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash"><span class="nb">unset </span>TMPDIR
mysql_install_db --verbose --user<span class="o">=</span><span class="sb">`</span>whoami<span class="sb">`</span> --basedir<span class="o">=</span><span class="s2">&quot;$(brew --prefix mysql)&quot;</span> <span class="se">\</span>
    --datadir<span class="o">=</span>/usr/local/var/mysql --tmpdir<span class="o">=</span>/tmp
</code></pre></div>
<p>Make a symlink to the MySQL socket so that PHP can find it where it expects to:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash">sudo mkdir -p /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
</code></pre></div>
<p>Relaunch MySQL:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash">launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
</code></pre></div>
<p>MySQL&rsquo;s user name is <code>root</code>; there is initially no password.  Set a password,
so no one can hack in:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash">sudo /usr/local/opt/mysql/bin/mysqladmin -u root password <span class="s1">&#39;YOUR_MYSQL_PASSWORD&#39;</span>
</code></pre></div>
<p>Try it out.  Create a test database:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash"><span class="nv">$ </span>mysql -uroot -p
<span class="o">[</span>enter password when prompted<span class="o">]</span>
mysql&gt; create database mytestdb;
mysql&gt; quit
</code></pre></div>
<p>Then put the following in ~/Sites/mysql.php:</p>
<div class="highlight"><pre><code class="php language-php" data-lang="php"><span class="cp">&lt;?php</span>
<span class="nv">$mysqli</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">mysqli</span><span class="p">(</span><span class="s1">&#39;localhost&#39;</span><span class="p">,</span> <span class="s1">&#39;root&#39;</span><span class="p">,</span> <span class="s1">&#39;YOUR_MYSQL_PASSWORD&#39;</span><span class="p">,</span> <span class="s1">&#39;mytestdb&#39;</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$mysqli</span><span class="o">-&gt;</span><span class="na">connect_error</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">die</span><span class="p">(</span><span class="s1">&#39;Connect Error (&#39;</span> <span class="o">.</span> <span class="nv">$mysqli</span><span class="o">-&gt;</span><span class="na">connect_errno</span> <span class="o">.</span> <span class="s1">&#39;) &#39;</span>
        <span class="o">.</span> <span class="nv">$mysqli</span><span class="o">-&gt;</span><span class="na">connect_error</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">echo</span> <span class="s1">&#39;Success... &#39;</span> <span class="o">.</span> <span class="nv">$mysqli</span><span class="o">-&gt;</span><span class="na">host_info</span> <span class="o">.</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span>
<span class="nv">$mysqli</span><span class="o">-&gt;</span><span class="na">close</span><span class="p">();</span>
<span class="cp">?&gt;</span><span class="x"></span>
</code></pre></div>
<p>Then:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash">open <span class="s2">&quot;http://localhost/~`whoami`/mysql.php&quot;</span>
</code></pre></div>
<p>After it works, delete the test database:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash"><span class="nv">$ </span>mysql -uroot -p
<span class="o">[</span>enter password when prompted<span class="o">]</span>
mysql&gt; drop database mytestdb;
mysql&gt; quit
</code></pre></div>
<h2>To install WordPress</h2>

<p>Download WordPress.  Suppose you have downloaded it as, for example,
~/Downloads/wordpress-3.5.1.zip.</p>

<p>Unzip it into a <code>wordpress</code> subdirectory of your Sites directory:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash"><span class="nb">cd</span> ~/Sites
unzip ~/Downloads/wordpress-3.5.1.zip
</code></pre></div>
<p>Make sure WordPress is able to write to the wp-content directory (so, for
example, WordPress can upload JPG files and so on).  Apache runs as user
<code>_www</code> in group <code>_www</code>, so we&rsquo;ll change the wp-content directory&rsquo;s group to
<code>_www</code>, and make sure it is group-writable:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash">sudo chgrp -R _www wordpress/wp-content
</code></pre></div>
<p>Try it out:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash">open <span class="s2">&quot;http://localhost/~`whoami`/wordpress&quot;</span>
</code></pre></div>
<p>You will be asked to enter the following information.  Enter is as shown below
(the only values you will need to change from the defaults are &ldquo;User Name&rdquo; and
&ldquo;Password&rdquo;):</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">Database name: wordpress
User Name:     root
Password:      (leave blank)
Database Host: localhost
Table Prefix:  wp_
</code></pre></div>
<p>Click Submit.  Oops, an error message.  You need to manually create the
<code>wordpress</code> database.</p>

<p>From the command line:</p>
<div class="highlight"><pre><code class="bash language-bash" data-lang="bash"><span class="nv">$ </span>mysql -uroot
mysql&gt; create database wordpress;
mysql&gt; quit
</code></pre></div>
<p>Now go back to the web page, and try again.  But it should now display a
different error message:</p>

<blockquote>
<p>Sorry, but I can&rsquo;t write the wp-config.php file.
You can create the wp-config.php manually and paste the following text into
it.</p>
</blockquote>

<p>Okay.  So do that.  Copy the text, and paste it into
<code>~/Sites/wordpress/wp-config.php</code>.  Then return to the web page and try one
more time; it should succeed.  (Note: We could have changed your filesystem&rsquo;s
permissions to give WordPress permission to write to <code>wp-config.php</code>, but I
prefer not to do that, for security reasons.)</p>

<p>You&rsquo;re done!  If you have any corrections, please <a href="https://www.twitter.com/mmorearty">let me know</a>.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Fixing Vim's indenting of HTML files]]></title>
    <link href="http://www.morearty.com/blog/2013/01/22/fixing-vims-indenting-of-html-files/"/>
    <updated>2013-01-22T14:28:17-08:00</updated>
    <id>http://www.morearty.com/blog/2013/01/22/fixing-vims-indenting-of-html-files</id>
    <content type="html"><![CDATA[<p>As Steve Losh <a href="http://stevelosh.com/blog/2010/09/coming-home-to-vim/#html-indentation-that-doesnt-suck">pointed
out</a>,
Vim&rsquo;s default indentation for HTML has a pretty severe quirk:</p>

<blockquote>
<p>The problem is that sometimes when I press return after a tag that I&rsquo;ve
already created Vim will unindent the new line <em>and the previous line</em>. This
is excruciatingly annoying.</p>
</blockquote>

<p>This was driving me crazy too.  I was able to track down the issue.</p>

<h2>The fix</h2>

<p>Add this line to your <code>~/.vimrc</code>:</p>
<div class="highlight"><pre><code class="vim language-vim" data-lang="vim">autocmd <span class="nb">FileType</span> html <span class="k">setlocal</span> <span class="nb">indentkeys</span><span class="p">-=</span>*<span class="p">&lt;</span>Return<span class="p">&gt;</span>
</code></pre></div>
<p>Once you do this, pressing the return key will only set the indentation on the
<em>newly created</em> line.  It will not touch the indentation of the previous line.</p>

<h2>How it works</h2>

<p>Vim&rsquo;s <code>indentkeys</code> controls which keystrokes will cause Vim&rsquo;s indentation logic
to kick in.  As the Vim help
<a href="http://vimdoc.sourceforge.net/htmldoc/indent.html#indentkeys-format">explains</a>,
if an asterisk appears before any keystroke in <code>indentkeys</code>, that means that
Vim should reindent the line before inserting that key.</p>

<p>So in other words, having <code>*&lt;Return&gt;</code> in your <code>indentkeys</code> means, &ldquo;When the
user presses Return, reindent the current line and then create the new line.&rdquo;</p>

<p>Doing <code>indentkeys-=*&lt;Return&gt;</code> removes that part of the <code>indentkeys</code> setting.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Questions about DHH's view of Dependency Injection in Ruby]]></title>
    <link href="http://www.morearty.com/blog/2013/01/07/questions-about-dhhs-view-of-dependency-injection-in-ruby/"/>
    <updated>2013-01-07T09:05:01-08:00</updated>
    <id>http://www.morearty.com/blog/2013/01/07/questions-about-dhhs-view-of-dependency-injection-in-ruby</id>
    <content type="html"><![CDATA[<p>DHH&rsquo;s <a href="http://david.heinemeierhansson.com/2012/dependency-injection-is-not-a-virtue.html">Dependency Injection is not a
virtue</a>
post is interesting.  He makes a good point, that Ruby is fundamentally
different in some ways from Java, therefore different rules may apply.  But
there are some aspects of his <code>Time.now</code> example that bothers me, and that I
think might be kind of important.  I&rsquo;d be interested to know how people who
have more experience with Ruby than I do would respond to these concerns.</p>

<p>If you are writing a test and you &ldquo;override&rdquo; the <code>Time.now</code> method, that might
be fine if you are testing just one little method.  But:</p>

<ol>
<li><p>This means you are overriding <code>Time.now</code> for any function that might be
called farther down the call stack.  Potentially error-prone.</p>

<p>I get the sense the Rubyist&rsquo;s response would be, &ldquo;You are worrying about the wrong things, you&rsquo;re worrying about things that are theoretically possible but are in practice unlikely to happen.&rdquo;  Is that right?</p>

<p>For that matter, I see what he is doing as basically a Ruby version of DI,
just not as good.  He is saying, &ldquo;Look, when you are coding in Ruby, when
you see <code>Time.now</code>, you just need to know that that is not as hard-coded as
it is in Java.  It might have been redirected.&rdquo;  Okay, then basically that
is DI, right?  Except that it affects all callers of <code>Time.now</code>, not just
the one you were intending to change.</p></li>
<li><p>That specific example only applies to testing scenarios &mdash; not to DI
in general.  I guess testing is the main place where DI is useful, though.
But that fact that the <code>stub</code> method is part of RSpec-Mocks implies that it
is intended to be used for testing, not other things.  Still, I find the DI
model a useful one, because I don&rsquo;t like hard-coded dependencies between
components, it tends to lead to trouble in my experience.</p></li>
<li><p>It breaks encapsulation.  The only way to test the <code>publish!</code> function in
his example is to look at its implementation.  Again, maybe the Rubyist&rsquo;s
response is &ldquo;You&rsquo;re worrying about the wrong things&rdquo;?</p>

<p>Maybe I&rsquo;m stuck in an old way of thinking &mdash; certainly I was a
hard-core believer on static typing for a very long time. (And still am, to
some degree &mdash; I still have not written anything of even medium size
with dynamic typing, and although I think dynamic typing is great for small
projects, I&rsquo;m still skeptical about it for anything else.)  But I don&rsquo;t
know, encapsulation has served me really well, and it is hard for me to
imagine that this example is sufficient reason for abandoning it.</p></li>
</ol>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Peer-to-peer message-passing to deal with overloaded cell phone networks?]]></title>
    <link href="http://www.morearty.com/blog/2012/07/05/peer-to-peer-message-passing-to-deal-with-overloaded-cell-phone-networks/"/>
    <updated>2012-07-05T11:14:21-07:00</updated>
    <id>http://www.morearty.com/blog/2012/07/05/peer-to-peer-message-passing-to-deal-with-overloaded-cell-phone-networks</id>
    <content type="html"><![CDATA[<p>At a crowded Fourth of July parade yesterday, I of course had nonexistent cell
phone/internet reception.  This is almost always true in any really crowded
place.</p>

<p>So I was wondering: Is it possible for someone (e.g. Apple or Google) to build
some sort of peer-to-peer message-passing system to allow messages to get in
and out?</p>

<p>The idea would be that a phone would detect that it was having a very hard time
connecting to the cell tower, but it could detect other phones in the immediate
vicinity.  So it would use some sort of handshake to find one that <em>was</em>
connected, and ask that device to be a proxy, and pass messages through.</p>

<p>For example, picture a crowded room with 50 people, no cell phones, and three
land lines.  Normally, this would mean that only three people at a time could
be on the phone.  But if the three people who are on the phone were somehow
capable of multiplexing, then someone else in the room could yell out, &ldquo;Hey, I
need to make a call&mdash;is anyone here connected to a land line?&rdquo;</p>

<p>One of the guys who is on the phone says, &ldquo;Yeah, tell me the number and I&rsquo;ll
dial it.&rdquo;  He dials the number, and then verbally relays the conversation back
and forth.  And like I said, he&rsquo;s multiplexing, so he is doing this while
continuing his own conversation.</p>

<p>Could cell phones do this?  If my phone successfully connects to a cell tower,
it could locally broadcast a signal saying, &ldquo;Hey, I&rsquo;m connected to the
Internet, if anyone cares.&rdquo;  Then, another local phone might hear that and say,
&ldquo;Oh good, because I haven&rsquo;t been able to connect&mdash;I want to proxy all my
messages through you.&rdquo;</p>

<p>There are, of course, problems that would have to be dealt with:</p>

<ul>
<li>Security&mdash;this is critical, of course.</li>
<li>Bandwidth consumption.  Can&rsquo;t let other people excessively drive up your
bandwidth usage.</li>
<li>Quality of service.  A system like this might not work for voice&mdash;it
would be better for things like text messages.  In fact, just doing it for
text messages, and nothing else, might be a good start, since that addresses
both bandwidth consumption and quality of service.</li>
</ul>

<p>But I am more interested in hearing whether this is a workable idea (or has
been done already), rather than about all the potential pitfalls.</p>

<p>Comments on on <a href="http://news.ycombinator.com/item?id=4204177">Hacker News</a> or
<a href="https://twitter.com/mmorearty">Twitter</a> please.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[French-style &laquo;quotation marks&raquo; are great for code samples]]></title>
    <link href="http://www.morearty.com/blog/2012/06/13/french-style-quotation-marks-are-great-for-code-samples/"/>
    <updated>2012-06-13T16:26:54-07:00</updated>
    <id>http://www.morearty.com/blog/2012/06/13/french-style-quotation-marks-are-great-for-code-samples</id>
    <content type="html"><![CDATA[<p>I recently came up with the idea of using French-style quotation marks to
surround replaceable parts in code samples, e.g.:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ cat «filename»
</code></pre></div>
<p>Another example is my answer
<a href="http://stackoverflow.com/questions/11023769/how-can-i-get-all-the-tags-that-have-been-applied-to-a-file-in-a-git-repository/11024635#11024635">here</a>.</p>

<p>I love this!  Because no one ever uses &laquo;&nbsp;&raquo; for anything else,
and because it works even in preformatted text that doesn&rsquo;t support bold or
italics.</p>

<p>On a Mac, type <strong>Option-\</strong> to get the open-quote character and
<strong>Shift-Option-\</strong> to get the close-quote character.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[fdb, the Flex debugger: Internals of how stepping works]]></title>
    <link href="http://www.morearty.com/blog/2011/04/10/fdb-the-flex-debugger-internals-of-how-stepping-works/"/>
    <updated>2011-04-10T16:24:19-07:00</updated>
    <id>http://www.morearty.com/blog/2011/04/10/fdb-the-flex-debugger-internals-of-how-stepping-works</id>
    <content type="html"><![CDATA[<p>Since I left Adobe last year, I haven&rsquo;t done much work in Flash or Flex, so I
haven&rsquo;t written much about them on this blog.  (In fact, I haven&rsquo;t written very
much about anything &ndash; this poor blog has been somewhat neglected.)</p>

<p>But a recent email exchange with Ilan Avigdor and Yoav Moran contained some
information that I think is worth sharing here.  They are &ldquo;creating a tool for
<a href="http://www.tikalk.com/flex/code-execution-viewer">visualizing code execution</a>
for AS3,&rdquo; and had some questions about the internal workings of <code>fdb</code>, the free
open-source command-line debugger that comes with the Flex SDK.  I wrote back
to them with some details, and I thought I would repost my notes here.  (This
post is pretty rough, because I&rsquo;m just taking the email conversation, doing a
little light editing, and then posting it.)</p>

<p>The part they wanted to know about is how stepping (step into, step over, etc.)
is handled by fdb.</p>

<h3>A command-line debugger for Flex?  And it&rsquo;s free?  And it&rsquo;s open-source?</h3>

<p>But first: Yes, it&rsquo;s true, there is a free, open-source command-line debugger
for Flex.  I get the feeling a lot of people are unaware of that.  Just as the
command-line compiler, <code>mxmlc</code>, is free and open-source, the same is true of
the debugger, <code>fdb</code>.  It, like all the other Flex tools, is written in Java.</p>

<p><code>fdb.jar</code> actually serves two purposes: </p>

<ol>
<li>It is a Java library with an API that is callable from any Java program you
write.  E.g. if you wanted to write your own WYSIWYG Flex debugger, you
could just put <code>fdb.jar</code> inside your app, and then call its Java API &ndash;
<code>stepInto()</code> and so on.</li>
<li>In addition, in the same jar is the command-line debugger.  The command-line
debugger portion of <code>fdb.jar</code> makes calls to the API portion of <code>fdb.jar</code>.</li>
</ol>

<p>The Java library portion of <code>fdb.jar</code> is actually opening a socket and
connecting to the Flash Player which is running in a separate process (e.g. in
your web browser).  Yes, there is a wire protocol, so you don&rsquo;t <em>have</em> to use
<code>fdb.jar</code> &ndash; you could write directly to the wire protocol &ndash; but that is
harder, especially since the wire protocol isn&rsquo;t publicly documented.</p>

<h3>Reading the source</h3>

<p>Top-level location: <a href="http://opensource.adobe.com">http://opensource.adobe.com</a> &ndash; this is the entry point
for all of Adobe&rsquo;s open-source code.</p>

<p>Flex SDK location: <a href="http://opensource.adobe.com/svn/opensource/flex/sdk/trunk">http://opensource.adobe.com/svn/opensource/flex/sdk/trunk</a>
&ndash; this is a Subversion repo, so for example you can download all the sources
with this command, to put them in a subdir called &ldquo;flex&rdquo; under the current
directory:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">svn co http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/ flex
</code></pre></div>
<p>(That will pull down a lot more than just fdb.)  fdb is in the
<code>modules/debugger</code> subdirectory of that.  Under <code>modules/debugger</code>,
<code>src/java/flash</code> contains the API portion, and <code>src/java/flex</code> contains the
code for the command-line fdb program.  The class
<code>flex.tools.debugger.cli.DebugCLI</code> is the entry class of the whole fdb program.</p>

<h3>How stepping works</h3>

<p>First, as in many debuggers, there are three kinds of stepping:</p>

<ul>
<li>Step into: Single-step, and if we step into a function call, then halt at the
first line of that function call.</li>
<li>Step over: Step over the current line until we reach the next line of the
current function.  Do not halt inside nested functions.</li>
<li>Step out: Step until we exit the current function.</li>
</ul>

<p>The function <code>runningLoop()</code> is one of the more important functions related to
stepping: It is in charge of repeatedly telling the Flash player to resume
until it decides it is time to stop.</p>

<p>Here is how stepping works:</p>

<p>When fdb sends any of the stepping-related commands to the flash player &ndash; step
in, step over, or step out &ndash; the player says, &ldquo;Okay then, how deep is the
callstack at the present time?&rdquo; and then uses either that number (for step
over), or that number plus one (for step in), or that number minus one (for
step out) as the target callstack depth for when the step command will be
finished.  And Flash&rsquo;s opcode instruction set includes a &ldquo;debugline&rdquo; opcode
that means &ldquo;I am at the beginning of a line of source code&rdquo; &ndash; so the Flash
player will only do this check of the callstack depth each time it reaches a
&ldquo;debugline&rdquo; opcode.</p>

<p>E.g. suppose the callstack has three functions on it, and you call &ldquo;step over&rdquo;.
Then the player records the number 3, which means, &ldquo;the next time I reach a
debugline opcode and the callstack depth is 3 or less, halt.&rdquo;  At that point,
the code might call into another function (so the callstack depth will be 4),
and that function might call into a whole bunch of others (so the callstack
depth will keep getting deeper); but eventually it will pop back to the next
line of the original function, and the callstack depth will be 3, and it will
halt.</p>

<p>Next scenario: Instead of step over, you call &ldquo;step in&rdquo;.  The player then
records a target callstack depth of 4 &ndash; again, this means, &ldquo;the next time I
reach a debugline opcode and the callstack depth is 4 or less, halt.&rdquo;  Which in
essence means that the very next debugline opcode will cause it to halt, no
matter whether the current line of code called another function (in which case
the callstack depth will be 4, because you&rsquo;ll be in the new function), or just
did something like an assignment to a variable (in which case it will be 3,
because you&rsquo;ll be on the next line of the same function), or did a &ldquo;return&rdquo; (in
which case it will be 2, because you will have returned to the caller).  But
it&rsquo;ll halt.</p>

<p>Last scenario: You call &ldquo;step out&rdquo;.  Then the player records a target callstack
depth of 2.  It will keep stepping until the current function eventually
returns.</p>

<p>Okay, so, your app: You always call &ldquo;step in&rdquo;.  Now suppose the current
callstack has only one function on it (so it has a callstack depth of 1); and
you call &ldquo;step in,&rdquo; so the player records this as &ldquo;halt the next time we reach
a debugline opcode and the callstack depth is 2 or less&rdquo;; but then the current
function does a &ldquo;return&rdquo;.  We are no longer in ActionScript code &ndash; the Flash
player&rsquo;s native code is back in charge.  It can do whatever it wants, but the
key point is, eventually, the next time it calls any ActionScript code for any
reason, and a &ldquo;debugline&rdquo; opcode is encountered, the ActionScript part of the
Flash player will notice that it is supposed to stop.  It doesn&rsquo;t matter that
the code that is now executing is totally unrelated to the code that was
executing before (e.g. the beginning of a new frame or whatever) &ndash; it will
stop.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[I love plain text]]></title>
    <link href="http://www.morearty.com/blog/2011/03/28/i-love-plain-text/"/>
    <updated>2011-03-28T15:06:27-07:00</updated>
    <id>http://www.morearty.com/blog/2011/03/28/i-love-plain-text</id>
    <content type="html"><![CDATA[<p>I&rsquo;m a programmer, so I&rsquo;ve always loved plain text, and I&rsquo;ve always been bad at
doing most things that require me to work with richer formats.  For example, if
you ask me to create some sort of schematic or diagram, I always spend way too
long working on it, and it never comes out looking very good.</p>

<p>That&rsquo;s why I am so excited with all the wonderful tools that are becoming more
and more prevalent, that allow me to work in the medium in which I am so
comfortable &ndash; good old plain text &ndash; and yet to output to very rich formats.</p>

<p>For example:</p>

<ul>
<li><p>I am writing this blog post in Markdown using the <a href="http://michelf.com/projects/php-markdown/">Markdown plugin for
Wordpress</a>.  Awesome!  I love it.
I no longer have to fight with the WordPress rich text editor.  <em>(Update
2/5/2013: Now using <a href="http://jekyllrb.com/">Jekyll</a>.  Even better.)</em></p></li>
<li><p>I recently needed to create some <a href="http://en.wikipedia.org/wiki/Sequence_diagram">UML Sequence
diagrams</a> to demonstrate
flow through the different components of a program I was writing.  I&rsquo;m on a
Mac, so I can&rsquo;t use Visio.  I spent a long time looking at a number of
different options, like OmniGraffle, Gliffy, and so on.  Finally, I found
<a href="http://www.websequencediagrams.com/">websequencediagrams.com</a>, which is
<em>awesome</em>.  It lets me write a plain-text description of the interactions
between the components &ndash; for example:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">iPhone-&gt;Server: send request
Server--&gt;iPhone: xml
</code></pre></div>
<p>&hellip; and it will instantly create the UML sequence diagram for me:</p>

<p><img src="http://www.websequencediagrams.com/cgi-bin/cdraw?lz=ICAgICAgICBpUGhvbmUtPlNlcnZlcjogc2VuZCByZXF1ZXN0CgAdCAAXBi0tPgAoBjogeG1sCg&amp;s=vs2010" alt="diagram"></p>

<p>Once you have this capability, the possibilities are endless.  For example,
websequencediagrams.com makes it <a href="http://www.websequencediagrams.com/embedding.html">easy to write your own
scripts</a> in Python,
Ruby, Java, or whatever, and create the sequence diagrams.  So the point
is, I can create the text representation locally on my own computer and
check it into source control, and then recreate the resulting diagram
whenever I want.</p></li>
<li><p><a href="http://yuml.me/">yUML</a> is similar, but for other kinds of UML diagrams
such as class diagrams.  Again, you just write it down in plain text, and
it lays out and creates a pretty diagram.  For example, with this input:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">[Customer]1-0..*[Address]
</code></pre></div>
<p>&hellip; you get this image:</p>

<p><img src="http://yuml.me/diagram/scruffy/class/%5BCustomer%5D1-0..*%5BAddress%5D" alt="diagram"></p></li>
<li><p>In case it wasn&rsquo;t obvious, both of the above services make it easy to just
put an <code>&lt;img&gt;</code> tag in your own web page and point to their server, and your
diagram will show up.</p></li>
<li><p>And then there are things like <a href="http://johnmacfarlane.net/pandoc/">PanDoc</a>,
which makes it possible to write an entire book in Markdown.  Today I came
across <a href="http://openmymind.net/2011/3/28/The-Little-MongoDB-Book">The Little MongoDB
Book</a> via Hacker
News.  So the guy writes the book in Markdown, and then runs PanDoc which
creates a very nice-looking PDF out of the whole thing.  And of course he
stores the original Markdown in GitHub.</p></li>
</ul>

<p>This is the way things are supposed to be.  It feels so right.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Mailing labels: Google vs. Apple]]></title>
    <link href="http://www.morearty.com/blog/2010/12/19/mailing-labels-google-vs-apple/"/>
    <updated>2010-12-19T01:00:44-08:00</updated>
    <id>http://www.morearty.com/blog/2010/12/19/mailing-labels-google-vs-apple</id>
    <content type="html"><![CDATA[<p>For years, my wife and I have used Microsoft Excel + Microsoft Word to do
mailing labels for Christmas cards. The workflow is weird and confusing, but at
least we are familiar with it.</p>

<p>Since I&rsquo;m a Google fan and an Apple fan, and feel that both companies are
really good at making things easy, and since my wife and I are both on Macs
now, I thought I&rsquo;d see how good a job those companies do.</p>

<p>For Google, searched for info on how to do mailing labels in Google Docs. They
claim to support labels, but their &ldquo;solution&rdquo; is hilariously bad: Start with a
document template (people upload tons of them), and then manually change each
label. Ha!</p>

<p>Apple&rsquo;s solution is hard to find (I found it by googling), but once you do find
it, it&rsquo;s awesome. Export your list to a CSV file, then import the data into the
Address Book app, and then say File &gt; Print. One of the printing choices is
Labels; and you can specify which Avery label type you want, and you&rsquo;re done!</p>

<p>And they did a beautiful job of handling a few issues I was worried about:</p>

<ul>
<li>I don&rsquo;t normally use Address Book, so it was okay with me if it clobbered
existing data that I had in there, but I was wondering if this would work for
people who do actively use Address Book. It works fine. First I created a new
&ldquo;Group&rdquo; called &ldquo;Christmas Labels 2010&rdquo;. Then I imported into that group. If
there are any imported entries that appear to be duplicates of existing
entries, it asks me what I want to do (merge, keep both, etc.). I just told
it to keep both. Then, after printing my labels, I deleted all the entries I
had imported, and then deleted the group.</li>
<li>My Excel spreadsheet is formatted in a way that isn&rsquo;t really compatible with
the Address Book fields. Address Book has separate fields for first name,
last name, address, city, state, zip. My spreadsheet just had three columns:
&ldquo;Last Name&rdquo; (which was actually the full name), &ldquo;Street&rdquo;, and &ldquo;City, State,
Zip&rdquo;. When I imported, Address Book did a good job of guessing which field
each one should go into, but of course it might import one entry with the
last name &ldquo;The Smith Family&rdquo; and no first name, and the city &ldquo;San Francisco,
CA 94134&rdquo;, and no state or zip code. Okay, that&rsquo;s incorrect. But it wasn&rsquo;t a
problem. When I said to print, the labels looked just fine. (And no, there
was not an extra space before &ldquo;The Smith Family&rdquo; on the labels, even though
it is trying to print &ldquo;<firstname> <lastname>&rdquo;.)</li>
<li>Although by default it didn&rsquo;t guess the correct encoding of the CSV file, I
was able to manually specify UTF-8, for the handful of entries that had
special characters.</li>
<li>A few entries had text that was too long to fit in the default font. Address
Book handles that gracefully &ndash; it just printed those ones in a smaller font.</li>
</ul>

<p>So it&rsquo;s a knockout punch, Apple wins.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Flex Builder tip: How to dismiss the "Add Watch Expression" dialog from the keyboard]]></title>
    <link href="http://www.morearty.com/blog/2009/05/18/flex-builder-tip-how-to-dismiss-the-add-watch-expression-dialog-from-the-keyboard/"/>
    <updated>2009-05-18T14:54:27-07:00</updated>
    <id>http://www.morearty.com/blog/2009/05/18/flex-builder-tip-how-to-dismiss-the-add-watch-expression-dialog-from-the-keyboard</id>
    <content type="html"><![CDATA[<p>One <img align="right"
src="./../../../../assets/2009/05/add-watch-expression-300x198.png"
alt="add-watch-expression" title="add-watch-expression" width="300"
height="198" class="alignnone size-medium wp-image-221" />of the most common
Flex Builder debugger complaints is that when you bring up the dialog to add a
new expression to the Expressions view (e.g. via right-click &gt; Add Watch
Expression), you cannot dismiss this dialog using the keyboard alone.  The
dialog has a multi-line edit box, and if you press Return, that just adds a
carriage return to the edit box. Similarly, trying to tab out of the edit box
doesn&rsquo;t work &ndash; it just inserts a tab character into the edit box.</p>

<p>This drives keyboard-heavy users (like me) crazy.  However, it turns out that
there <em>is</em> a way to dismiss this dialog from the key:</p>

<p><strong>Type Shift+Return instead of Return.</strong></p>

<p>There is, in fact, a good reason why this dialog has a multi-line edit box.  As
explained in this <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=271411">Eclipse
bug</a>, some languages
(including Java) allow you to enter more than just a simple expression into
this box.  And since the dialog comes from Eclipse&rsquo;s code rather than from Flex
Builder&rsquo;s, we can&rsquo;t just change it to have a single line.</p>

<p>Since this is such a common point of frustration for Flex Builder users, in the
above-linked bug I have asked that they find some way to make this easier for
people to deal with, e.g. by perhaps having a short message in the dialog
mentioning Shift+Return.  But in any case, you now know the secret handshake &ndash;
enjoy!</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[All Flex developers, please do this.]]></title>
    <link href="http://www.morearty.com/blog/2009/03/06/all-flex-developers-please-do-this/"/>
    <updated>2009-03-06T11:19:29-08:00</updated>
    <id>http://www.morearty.com/blog/2009/03/06/all-flex-developers-please-do-this</id>
    <content type="html"><![CDATA[<p>Even if you aren&rsquo;t a Mac user, please <a href="http://blog.pixelbreaker.com/flash/as30-mousewheel-on-mac-os-x/">do
this</a> to your
Flex apps.</p>

<p>Even if you aren&rsquo;t the kind of person who uses the scroll wheel on your mouse
or two-finger scroll on your trackpad, please do it.</p>

<p>If you do, you will make some of your users very very happy.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[How to capture the compilation options used by Flex Builder]]></title>
    <link href="http://www.morearty.com/blog/2009/01/23/how-to-capture-the-compilation-options-used-by-flex-builder/"/>
    <updated>2009-01-23T12:10:48-08:00</updated>
    <id>http://www.morearty.com/blog/2009/01/23/how-to-capture-the-compilation-options-used-by-flex-builder</id>
    <content type="html"><![CDATA[<p>Suppose you are trying to set up a nightly build system &ndash; your developers use
Flex Builder during the day, and you are creating an Ant task that runs every
night. And you want the Ant task to use exactly the same build settings that
are used by the developers.</p>

<p><code>mxmlc</code> and <code>compc</code> have a <code>-dump-config</code> option to dump all settings to a
file. Later, the settings in that file can be read back in with <code>-load-config</code>.</p>

<p>So, do this:</p>

<ul>
<li>  In Flex Builder, do Project Properties</li>
<li>  Click the &ldquo;Flex Compiler&rdquo; tab</li>
<li>  In the &ldquo;Additional compiler arguments&rdquo; box, add <code>-dump-config
«full-path-to-output-file»</code>. For example, on Windows, <code>-dump-config
C:\myconfig.xml</code>; on Mac, <code>-dump-config /Users/«myname»/myconfig.xml</code>. (If
you use a relative path, the file will be put in some odd hard-to-find
place.)</li>
<li>  Click OK. If Build Automatically is on, just clicking OK will cause the
file to be built; if it is off, do a build now.</li>
<li>  Now that the settings have been dumped, go back to your project settings
and remove the <code>-dump-config</code> option.</li>
<li>  Tweak the settings file as necessary (one thing you will almost certainly
want to do is change <code>&lt;debug&gt;true&lt;/debug&gt;</code> to <code>&lt;debug&gt;false&lt;/debug&gt;</code> if
your nightly build is supposed to do a release build), and use it in your
nightly build script.</li>
</ul>

<p>Please be aware that this only captures compiler settings; it doesn&rsquo;t capture
all the other little things that Flex Builder does for you, like compiling Flex
library projects that your project depends on, copying non-embedded assets to
the output directory, optimizing modules for the application, extracting RSLs,
copying the HTML template, and so on.</p>

<p>More info
<a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=kb404341">here</a>.
Please read that, it has additional info you will probably need.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[UI race conditions]]></title>
    <link href="http://www.morearty.com/blog/2008/12/21/ui-race-conditions/"/>
    <updated>2008-12-21T23:54:02-08:00</updated>
    <id>http://www.morearty.com/blog/2008/12/21/ui-race-conditions</id>
    <content type="html"><![CDATA[<p>I&rsquo;m sure this has happened to you once in a while: You&rsquo;re doing several things
at the same time on the computer, e.g. perhaps you click to launch some slow
program, and while that is launching you go over to your web browser to kill a
few seconds reading something. You try to click a link, but <em>oops</em> &ndash; just when
you were about to click it, the other program finishes loading, and you have
accidentally clicked something in it.</p>

<p>A variation of that happened to me just today. I decided to try Yahoo Chess
(and I&rsquo;m proud to say I won my game). You enter a room, e.g. the beginner room,
and then there is a list of tables; you click to join a particular table. But
every few seconds, the list of tables keeps refreshing, so the button you were
about to click could have suddenly disappeared &ndash; or worse, turned into a
button for a different table you didn&rsquo;t intend to join.</p>

<p>What&rsquo;s interesting to me (I don&rsquo;t know why, maybe because I&rsquo;m a geek) is that
this is a real-life version (if using the computer is considered real life) of
the sort of race condition horribleness we all run into when we write
multithreaded code. Thread 1 tries to increment a variable, but <em>oops</em>, thread
2 sneaks in there and changes it! Urgh.</p>

<p>Does this ever come up in <em>real</em> real life (as opposed to real life while using
a computer)? Yes, of course &ndash; one good example is the awkward little dance we
all do once in a while when trying to walk past someone else who is coming the
other way. Both step to the right, oops, both step to the left, oops!</p>

<p>In the case of computer UI, I can think of two ways to alleviate this problem
(I am not claiming any incredible insight here, I think these are pretty
obvious):</p>

<ol>
<li>Animation can help. E.g. in the example of the Yahoo Chess list of tables,
when the list redraws, rather than having it redraw instantly as it does
now, maybe the individual rows of the list should slide to their new
positions. That gives a person&rsquo;s eye the visual feedback, &ldquo;Wait, don&rsquo;t click
just now.&rdquo; Animation is sort of the computer equivalent of what usually
helps avoid this problem in real-life scenarios: Most of the time, the fact
that you can see the other person moving and adapt to their movement gives
your brain enough time to avoid a collision.</li>
<li>Maybe disable the mouse (and keyboard if appropriate) for a fraction of a
second, e.g. maybe &frac14; second, immediately after a change, e.g. immediately
after the list of chess tables was updated, or immediately after a program
opens a new window or dialog.</li>
</ol>

<p>Of course, it would often be appropriate to combine both of those techniques:
disable the mouse, do the animation, and then re-enable the mouse. If done that
way, the mouse could be immediately re-enabled when the animation was done &ndash;
no need to wait for &frac14; second more after the animation is done, because the
person has already had sufficient time to process what is happening and avoid
an accidental click.</p>

<p>What do you think? I&rsquo;m sure none of this is terribly original &ndash; I imagine lots
of research on this topic has been done. I just haven&rsquo;t come across it.
(Sometimes blogging scares me, because the Internet is so huge that no matter
how original a particular thought of mine might be, the odds are extremely good
that someone else has already had it, and has said it on the Internet, and thus
it&rsquo;s already in the Google index, and so should I really bother. Reminds me of
a joke that A. Whitney Brown made many many years ago in Saturday Night Live:
&ldquo;There are a billion people in China. Think about that. That means if you&rsquo;re a
one-in-a-million kind of guy, there are a thousand other people exactly like
you.&rdquo;)</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Extending Flex Builder: sample code for design.xml]]></title>
    <link href="http://www.morearty.com/blog/2008/11/19/extending-flex-builder-sample-code-for-designxml/"/>
    <updated>2008-11-19T23:46:13-08:00</updated>
    <id>http://www.morearty.com/blog/2008/11/19/extending-flex-builder-sample-code-for-designxml</id>
    <content type="html"><![CDATA[<p>Thanks to everyone who came to <a href="http://davidzuckerman.com/adobe/">David</a>&rsquo;s and
my talk at MAX today, <a href="http://davidzuckerman.com/adobe/max-2008-extending-flex-builder-presentation/">Extending Flex
Builder</a>.
I promised to post the sample code for the part of the talk which discussed
design.xml.</p>

<p>So <a href="./../../../../assets/2008/11/max2008.zip">here it
is</a>.  This
ZIP file contains two projects:</p>

<ul>
<li>  <code>MyLibrary</code> is the main interesting part.  It contains <code>design.xml</code>, a Flex
manifest, and a sample component.  See the slides (linked above) for an
explanation of how all this stuff hooks together.</li>
<li>  <code>MyFlexProject</code> is just a simple Flex Project that has <code>MyLibrary</code> on its
library path, so that you can see that when you open the Flex project&rsquo;s
main app in design view, the library&rsquo;s Calculator component shows up in the
&ldquo;Mike&rsquo;s stuff&rdquo; folder of the Components view (as opposed to the default,
the &ldquo;Custom&rdquo; folder), and that if you click on the calculator that is
already in the document, the list of properties in the Properties view has
been customized, with the &ldquo;Layout:&rdquo; property showing up there.</li>
</ul>

<p>To reiterate, the sample by itself isn&rsquo;t quite enough &ndash; you really need to see
the slides (starting at slide #23) to understand the context.  And, I will soon
be writing an Adobe Developer Center article with much more detail.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[News about tomorrow's "Extending Flex Builder" talk]]></title>
    <link href="http://www.morearty.com/blog/2008/11/18/news-about-tomorrows-extending-flex-builder-talk/"/>
    <updated>2008-11-18T19:12:46-08:00</updated>
    <id>http://www.morearty.com/blog/2008/11/18/news-about-tomorrows-extending-flex-builder-talk</id>
    <content type="html"><![CDATA[<p>There are two things I wanted to mention about the talk
<a href="http://davidzuckerman.com/adobe/">David</a> and I are doing tomorrow, &ldquo;Extending
Flex Builder&rdquo; &ndash; David already mentioned this on his blog, but in case you
missed it, the documentation team has posted the docs for Flex Builder&rsquo;s  <a href="http://www.adobe.com/livedocs/flex/3/extensibility/">Code
Model API and Design Model
API</a> up on adobe.com.
Previously, the only way to find this documentation was by running Flex Builder
and then going to the help &ndash; but as you all know, if Google can&rsquo;t find it, it
doesn&rsquo;t exist.  So, thanks, doc team!</p>

<p>Also, David posted the sample code for tomorrow&rsquo;s talk.  See his post
<a href="http://davidzuckerman.com/adobe/2008/11/18/max-2008-sample-content-for-extending-flex-builder/">here</a>.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[New Flex Builder debugger features: Conditional breakpoints, function calls from expressions, watchpoints, and more]]></title>
    <link href="http://www.morearty.com/blog/2008/11/18/new-flex-builder-debugger-features-conditional-breakpoints-function-calls-from-expressions-watchpoints-and-more/"/>
    <updated>2008-11-18T02:41:45-08:00</updated>
    <id>http://www.morearty.com/blog/2008/11/18/new-flex-builder-debugger-features-conditional-breakpoints-function-calls-from-expressions-watchpoints-and-more</id>
    <content type="html"><![CDATA[<p>I wanted to tell you all about some of the exciting debugger features we&rsquo;ve
been working on, which will be in Flex Builder 4, including several of the most
common requests.  All of the features listed below are in the preview release
of Flex Builder that we gave out at MAX, with the, um, exception of exception
breakpoints, which are not yet in the product.  If you were at MAX, give these
features a try, and let us know your feedback!  If you weren&rsquo;t able to make it
to MAX, don&rsquo;t worry, this stuff will eventually show up in a beta on Adobe
Labs, and then of course in the final product as well.</p>

<h3>Conditional breakpoints</h3>

<p>Suppose you have set a breakpoint, but that line of code is reached hundreds of
times, and you only care about the case where a variable &lsquo;x&rsquo; is unexpectedly
equal to null. Just right-click on the breakpoint, go to its properties, and
add the condition:</p>

<p><img src="./../../../../assets/2008/11/conditional-breakpoint1.png" alt="" title="conditional-breakpoint1" width="400" height="352" class="alignnone size-full wp-image-164" /></p>

<p>For some extra breakpointy goodness, you can also set a hit count on any
breakpoint &mdash; e.g. a hit count of 5 means, don&rsquo;t halt until the fifth time
that line of code is reached.</p>

<h3>Awesome new expression evaluator: function calls, E4X, regular expressions, etc.</h3>

<p>Going along with conditional breakpoints is a vastly improved expression
evaluator. It is used when evaluating conditional breakpoints, in the
Expressions view, and in debugger tooltips.</p>

<p>For one thing, you can now make function calls directly from the Expressions
view (as well as from conditional breakpoints):</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="n">mystr</span><span class="o">.</span><span class="na">indexOf</span><span class="o">(</span><span class="s2">&quot;test&quot;</span><span class="o">)</span>
</code></pre></div>
<p>Also, regular expressions and E4X expressions can be quite tricky to debug;
with the new expression evaluator, you can just type them into the Expressions
view and immediately see the value. (The one exception is you can&rsquo;t use E4X
filter expressions such as <code>myxmlvar.(@id==&#39;3&#39;)</code>.) For example, suppose
&ldquo;customers&rdquo; is an XML object &mdash; you can do expressions like these in the
Expressions view:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="n">myCustomersXML</span><span class="o">.</span><span class="na">customer</span><span class="o">.</span><span class="err">@</span><span class="n">name</span>
<span class="n">myCustomersXML</span><span class="o">..</span><span class="n">zipCode</span>
<span class="n">myCustomersXML</span><span class="o">.</span><span class="na">customer</span><span class="o">[</span><span class="mi">0</span><span class="o">].</span><span class="err">@</span><span class="n">name</span>
</code></pre></div>
<p>Here is a regular-expression example that you could put in the Expressions view
or a breakpoint condition:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="n">mystr</span><span class="o">.</span><span class="na">match</span><span class="o">(</span> <span class="sr">/[0-9]+/ig</span> <span class="o">)</span>
</code></pre></div>
<p>You can use the ternary ( ?: ) operator:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="n">mystr</span><span class="o">.</span><span class="na">length</span><span class="o">&gt;=</span><span class="mi">3</span> <span class="o">?</span> <span class="n">mystr</span><span class="o">.</span><span class="na">charAt</span><span class="o">(</span><span class="mi">2</span><span class="o">)</span> <span class="o">:</span> <span class="s2">&quot;too short&quot;</span>
</code></pre></div>
<p>You can use the &ldquo;is&rdquo; operator (this is especially useful in conditional
breakpoints):</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="n">obj</span> <span class="k">is</span> <span class="n">String</span>
</code></pre></div>
<p>The possibilities are limitless.  <code>===</code>, <code>!==</code>, string concatenation, etc.
&mdash; almost any other ActionScript expression you can think of, you can put
it in the Expressions view or a breakpoint condition.</p>

<h3>Watchpoints</h3>

<p>Watchpoints tell the debugger to immediately halt when the value of a
particular variable changes.  Suppose you have a variable whose value keeps
changing out from under you, and you can&rsquo;t figure out who is changing it.  With
a watchpoint, it&rsquo;s trivial &mdash; just set the watchpoint and run your code.
(Flex Builder watchpoints are set on a particular <i>instance</i> of a
variable.  For example, you set a watchpoint on the _width field of a button
&ldquo;myButton&rdquo;, not on the _width field of all Buttons.)</p>

<p><img src="./../../../../assets/2008/11/toggle-watchpoint.png" alt="" title="toggle-watchpoint" width="400" height="222" class="alignnone size-full wp-image-165" /></p>

<h3>Exception breakpoints</h3>

<p>The debugger always halts immediately whenever there is an uncaught exception.
But sometimes, you want the debugger to halt even on an exception that
<i>is</i> going to be caught by a <code>try/catch</code> block in your code.</p>

<p>That&rsquo;s what exception breakpoints will let you do.  You will be able to say,
for example, &ldquo;Always halt in the debugger whenever a <code>TypeError</code> is thrown,
even if it is going to be caught.&rdquo;</p>

<h3>Run to line</h3>

<p>A minor feature but still quite nice to have: Run to Line (Cmd+R on Mac, Ctrl+R
on Windows) is a quick way to set a temporary breakpoint on the current line,
then run until you get there, and then automatically clear the temporary
breakpoint.</p>

<p><img src="./../../../../assets/2008/11/run-to-line.png" alt="" title="run-to-line" width="400" height="203" class="alignnone size-full wp-image-167" /></p>

<h3>Network monitor</h3>

<p>A major addition, this allows you to easily see the network traffic that is
going back and forth between your app&rsquo;s front end and its back end.</p>

<p>Click for a closer view:
<a href="./../../../../assets/2008/11/network-monitor.png"><img src="./../../../../assets/2008/11/network-monitor-300x279.png" alt="" title="network-monitor" width="300" height="279" class="alignnone size-medium wp-image-168" /></a></p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[MAX talk: Extending Flex Builder]]></title>
    <link href="http://www.morearty.com/blog/2008/10/30/max-talk-extending-flex-builder/"/>
    <updated>2008-10-30T12:07:23-07:00</updated>
    <id>http://www.morearty.com/blog/2008/10/30/max-talk-extending-flex-builder</id>
    <content type="html"><![CDATA[<p>I&rsquo;ve been busily working on slides the the MAX talk that David Zuckerman and I
are giving together, <a href="http://max.adobe.com/na/sessions/browser/#863">Extending Flex
Builder</a>.  This will be an
interesting session for people who want to extend Flex Builder with their own
add-ons.</p>

<p>The topics we&rsquo;ll be covering are:</p>

<ul>
<li>  <strong>The Code Model.</strong> David will give this portion of the talk. The Code
Model is an API that lets you programmatically browse and modify the set of
ActionScript classes, functions, etc. that are in the user&rsquo;s code.</li>
<li>  <strong>The Design Model.</strong> This is another API that lets you programmatically
browse and modify the MXML portions of the user&rsquo;s code.</li>
<li>  If you write your own SWC (Flex library project) and want to customize how
it shows up in the Components view when you give the SWC to another user,
and also how it appears in the Properties view when they have an instance
of your component selected in design view, you can add a file called
<strong>design.xml</strong> to your SWC.</li>
<li>  If we have time, we&rsquo;ll also give a very brief introduction to <strong>writing
Eclipse plug-ins</strong>, which is necessary if you are going to be using the
Code Model and the Design Model. Not sure if there will be time for this,
because there is so much other stuff we&rsquo;re trying to squeeze in.</li>
</ul>

<p>Hope to see you there!</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Typing with one hand is hard :-(]]></title>
    <link href="http://www.morearty.com/blog/2008/08/18/typing-with-one-hand-is-hard/"/>
    <updated>2008-08-18T10:03:56-07:00</updated>
    <id>http://www.morearty.com/blog/2008/08/18/typing-with-one-hand-is-hard</id>
    <content type="html"><![CDATA[<p>About a week ago, the Flex team took the afternoon off to go to the park and
play kickball. Yeah that&rsquo;s right, the game for little kids, like baseball
except that you kick a big red rubber ball.</p>

<p>Wheeeeeee <em>owwww</em>.  Catching a fly ball (at least I caught it), I jammed my
finger. Turned out I fractured the fifth metacarpal bone in my hand, and will
be wearing a brace and/or cast for four to six weeks.</p>

<p>This is making it ridiculously hard to type. I don&rsquo;t really want to take any
time off work, because I just got back from a nice long sabbatical and am eager
to get back to Flex Builder features. So I&rsquo;m just going to keep plugging away,
albeit a lot more slowly than usual.</p>

<p>Voice recognition software helps with email and the like, but not with coding.
I even had another weird but creative idea that didn&rsquo;t quite pan out: one funny
thing about this is that with the brace on my hand, it is actually easier to
type on my iPhone than on a computer keyboard. (I am writing this blog post on
the iPhone.) So, I installed VNC software on my computer, and then installed
Mocha VNC Lite on my iPhone. That way, I can use the iPhone got typing on my
computer! But alas, when you do that, you don&rsquo;t get the iPhone&rsquo;s auto-correct
capabilities, and without that, the iPhone was too tedious to type on.</p>

<p>Anyway, I am plugging away on lots of really cool debugger features for Flex
Builder 4. I can&rsquo;t tell you what they are, but I just can&rsquo;t resist mentioning
that our awesome summer intern, Sedat Akkus, has implemented one of the
most-requested debugger features. So what is the feature? Well, that&rsquo;s a
secret, but it rhymes with &ldquo;fronditional schmakepoints.&rdquo;</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Mac voices]]></title>
    <link href="http://www.morearty.com/blog/2008/08/13/mac-voices/"/>
    <updated>2008-08-13T22:48:12-07:00</updated>
    <id>http://www.morearty.com/blog/2008/08/13/mac-voices</id>
    <content type="html"><![CDATA[<p>I was trying to free up some disk space on my Mac, so I ran <a href="http://www.derlien.com/">Disk Inventory
X</a> to help me find big files I could delete. I found a
pretty big (669MB) file called
/System/Library/Speech/Voices/Alex.SpeechVoice/Contents/Resources/PCMWave. I
suspected &ldquo;Alex&rdquo; was probably one of the voices that can be used with the Mac&rsquo;s
text-to-speech feature, and that turned out to be right: If you go to System
Preferences &gt; Speech, you can find Alex there.</p>

<p>The PCMWave file for Alex is <em>much</em> bigger than the PCMWave file for any other
voice, so I wasn&rsquo;t surprised to find that Alex sounds far more realistic than
any other voice. Nonetheless, I&rsquo;m gonna kill him, because he is taking too much
of my disk space.</p>

<p>In any case, I amused myself by listening to all the voices. Try clicking &ldquo;Show
More Voices&rdquo; &ndash; the &ldquo;Deranged&rdquo; voice made me laugh out loud.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Netflix Notes: Add a "note to self" next to movies in your queue]]></title>
    <link href="http://www.morearty.com/blog/2008/07/28/netflix-notes-add-a-note-to-self-next-to-movies-in-your-queue/"/>
    <updated>2008-07-28T23:43:31-07:00</updated>
    <id>http://www.morearty.com/blog/2008/07/28/netflix-notes-add-a-note-to-self-next-to-movies-in-your-queue</id>
    <content type="html"><![CDATA[<h3>To install:</h3>

<ul>
<li>Install <a href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a></li>
<li>Restart Firefox</li>
<li>Install <a href="http://userscripts.org/scripts/source/30744.user.js">Netflix Notes</a></li>
</ul>

<h3>Description:</h3>

<p>This happens to me all the time: I decide to add a movie to my Netflix queue &ndash;
perhaps because it was recommended by a friend, perhaps because I saw a good
review, perhaps for some other reason.</p>

<p>Then, months later, I can&rsquo;t remember why I put it in my queue!  To address this
problem, I wrote a little Firefox Greasemonkey script called Netflix Notes.</p>

<p>Netflix Notes changes your Netflix queue so that you can add a private &ldquo;note to
self&rdquo; on each movie in your queue.  The main point of this is to remind
yourself why you added a particular movie &ndash; e.g. because a friend recommended
it, you read a good review, and so on.</p>

<p>It only works with the Firefox web browser.  If you are using another browser,
such as Internet Explorer or Safari, Netflix Notes won&rsquo;t work for you.</p>

<p>I would love it if Netflix obsoleted my work by integrating this functionality
natively into their website!  But in the meantime, you can use my program.</p>

<h3>30-second demo:</h3>

<p><object classid="clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b" width="499" height="285" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0"><param name="src" value="./../../../../assets/2008/07/netflixnotes.mov" /><param name="autoplay" value="false" /><embed type="video/quicktime" width="499" height="285" src="./../../../../assets/2008/07/netflixnotes.mov" autoplay="false"></embed></object></p>

<h3>Frequently Asked Questions:</h3>

<p><strong>Q: Can other people see my notes?</strong> <br>
A: No.  The notes are stored on your computer, not out on the Internet.  Only someone using your computer can see your notes.</p>

<p><strong>Q: Where, exactly, are the notes stored?</strong> <br>
A: They are stored in your Firefox profile.  To see them, navigate to <a href="about:config">about:config</a>, and then type &ldquo;netflix&rdquo; into the filter box.</p>

<p><strong>Q: You should store the notes on the Internet!  I want to be able to see them from every computer I use.</strong> <br>
A: Yes, I would love to add that capability; but I haven&rsquo;t had a chance to do so yet.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[ActionScript's different ways to convert an object to a string]]></title>
    <link href="http://www.morearty.com/blog/2008/07/28/actionscripts-different-ways-to-convert-an-object-to-a-string/"/>
    <updated>2008-07-28T13:47:04-07:00</updated>
    <id>http://www.morearty.com/blog/2008/07/28/actionscripts-different-ways-to-convert-an-object-to-a-string</id>
    <content type="html"><![CDATA[<p>ActionScript has several different ways to convert an object to a string, and
figuring out which one to use can be confusing. This post compares them, and
tries to give you a deeper understanding of what is going on.</p>

<ul>
<li>  <code>String(myobj)</code> almost always succeeds; may return <code>&quot;null&quot;</code> or
<code>&quot;undefined&quot;</code>. This is usually the behavior you want.</li>
<li>  <code>&quot;&quot; + myobj</code> is effectively the same as <code>String(myobj)</code>, so you can use
this instead if you prefer.</li>
<li>  <code>myobj.toString()</code> calls the <code>toString()</code> member function &ndash; in most cases
this ends up being equivalent to <code>String(myobj)</code>, but if myobj is <code>null</code> or
<code>undefined</code>, <code>myobj.toString()</code> will throw an exception.</li>
<li>  <code>myobj as String</code> will return a string if myobj is a String, but will
return <code>null</code> if myobj is of some other type.</li>
<li>  For objects of type XML or XMLList, don&rsquo;t forget about
<code>myobj.toXMLString()</code>.</li>
</ul>

<h3><code>String(myobj)</code></h3>

<p>This is often the best choice. If you don&rsquo;t remember anything else from this
post, just remember that <code>String(myobj)</code> is the &ldquo;safest&rdquo; way to convert an
object to a string.</p>

<p>Although <code>String</code> is a type, <code>String()</code> is also a function. It isn&rsquo;t a
constructor &ndash; it is a regular function. Its behavior is to take whatever
argument you passed it, and convert it to a String.</p>

<p>This function will pretty much always succeed without throwing an exception.
The only case where it will throw an exception is the unlikely case that
<code>myobj.toString()</code> gets called and that function throws an exception.</p>

<p>The behavior of <code>String()</code> is formally defined by section 9.8 of the
<a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript
spec</a>.
(Note, this is confusing: When the ECMAScript spec refers to &ldquo;ToString&rdquo; or
&ldquo;[[ToString]]&rdquo;, they are not talking about the <code>toString()</code> function &ndash; they
are talking about the formal definition of what ECMAScript should do if it
needs to convert any object to a string.)</p>

<p>The main thing to remember is that it will always return a string &ndash; e.g. if
myobj is <code>null</code>, <code>String(myobj)</code> will return the string <code>&quot;null&quot;</code>, and if myobj
is <code>undefined</code>, <code>String(myobj)</code> will return the string <code>&quot;undefined&quot;</code>. If myobj
is a user-defined type, <code>String()</code> will end up calling its <code>toString()</code>
function.</p>

<h3><code>&quot;&quot; + myobj</code> (or <code>myobj + &quot;&quot;</code>)</h3>

<p>This is functionally equivalent to <code>String(myobj)</code>. Because of the rules of
ECMAScript&rsquo;s <code>+</code> operator, <code>&quot;&quot; + myobj</code> will result in <code>String(myobj)</code> being
performed on the second argument, and then being concatenated with the empty
string. Concatenation with the empty string is very efficient in the Flash
player, so don&rsquo;t worry about that.</p>

<h3><code>myobj.toString()</code></h3>

<p>This is fine for most cases &ndash; it will work on numbers, booleans, user-defined
objects, strings, etc. &ndash; but if myobj is <code>null</code> or <code>undefined</code>, this will
throw an exception. Explicitly saying <code>myobj.toString()</code> means you explicitly
want to call the <code>toString()</code> member function of myobj, but if myobj is <code>null</code>
or <code>undefined</code>, then of course it can&rsquo;t have any member functions.</p>

<h3><code>myobj as String</code></h3>

<p>You won&rsquo;t use this very often. The <code>&quot;as&quot;</code> operator means, &ldquo;If the object is
already an instance of the specified type, then cast it to the specified type
and return it; otherwise, return null.&rdquo; So <code>myobj as String</code> will return myobj
cast to a String if myobj is already a String, and will return <code>null</code> if myobj
is any other type. In most cases this is not the behavior you are looking for.</p>

<h3><code>myobj.toXMLString()</code></h3>

<p>Don&rsquo;t forget that if myobj is of type XML or XMLList, then <code>String(myobj)</code> and
<code>myobj.toString()</code> will work, but may or may not give the result you wanted;
you may want <code>myobj.toXMLString()</code> instead. See part 5 of <a href="/blog/2007/03/13/common-e4x-pitfalls/">Common E4X
Pitfalls</a>.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Announcement: AIR being ported to CP/M]]></title>
    <link href="http://www.morearty.com/blog/2008/04/01/announcement-air-being-ported-to-cpm/"/>
    <updated>2008-04-01T11:30:09-07:00</updated>
    <id>http://www.morearty.com/blog/2008/04/01/announcement-air-being-ported-to-cpm</id>
    <content type="html"><![CDATA[<p>I am excited to announce that Adobe, in its continuing efforts to port AIR to
as many platforms as possible, has begun work on porting AIR to CP/M.  Today I
brought my beautiful old Osborne 1 in to the office to get started on the job.</p>

<p>The project is off to a slow start &ndash; at this point, the computer still doesn&rsquo;t
boot.</p>

<p><img src="./../../../../assets/2008/04/osborne.jpg"
alt="osborne.jpg" /></p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Action-Oriented Programming]]></title>
    <link href="http://www.morearty.com/blog/2008/03/12/action-oriented-programming/"/>
    <updated>2008-03-12T09:18:35-07:00</updated>
    <id>http://www.morearty.com/blog/2008/03/12/action-oriented-programming</id>
    <content type="html"><![CDATA[<p>I just have to share this great term that my brother
<a href="http://www.ducklet.com/">Brian</a> came up with a while back on a <a href="http://discuss.joelonsoftware.com/default.asp?biz.5.378629.21">Joel on
Software discussion
board</a>:
Action-Oriented Programming.</p>

<blockquote>
<p>Regarding motivation to get started implementing a product idea once you have
one:</p>

<p>Whatever you do, do something.</p>

<p>Us programmers, we tend to overanalyze things. Lots of up-front design,
trying to decide if it&rsquo;s the right thing to do, not sure if we have enough
education yet, etc. But from what I&rsquo;ve read about successful entrepreneurs,
they are DOERS. They&rsquo;re Action-Oriented.</p>

<p>So I&rsquo;m inventing a new term:</p>

<p><strong>Action-Oriented Programming:</strong> writing the damn program instead of thinking
about writing it.</p>
</blockquote>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Open Source Flex: The candy store is now unlocked.]]></title>
    <link href="http://www.morearty.com/blog/2008/02/25/open-source-flex-the-candy-store-is-now-unlocked/"/>
    <updated>2008-02-25T11:13:41-08:00</updated>
    <id>http://www.morearty.com/blog/2008/02/25/open-source-flex-the-candy-store-is-now-unlocked</id>
    <content type="html"><![CDATA[<p><a href="http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK">The Flex SDK is now open
source.</a>  To whet
your appetite and get your brain going on some of the possibilities that this
opens up, here are a few tidbits of information:</p>

<ul>
<li><p>The <a href="http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/">trunk</a>
directory is where active development is taking place on Flex 4 (codename
Gumbo). Start there if you want to track Flex 4, contribute patches, and so
on.</p></li>
<li><p>The
<a href="http://opensource.adobe.com/svn/opensource/flex/sdk/branches/3.0.x/">3.0.x</a>
directory is where Flex 3 is kept. This is a stable branch that will only
be changed if there are patches to Flex 3. Start there if you want to play
with or modify the Flex 3 source.</p></li>
<li><p>In the rest of the bullet points below, any directory I mention exists as a
subdirectory of both the trunk and the 3.0.x branch.</p></li>
<li><p>The entire source of the compiler is in there. This includes two main
parts: mxmlc (in the modules/compiler directory) and asc (in the
modules/asc directory). asc is the lower-level component that parses and
compiles ActionScript source code; mxmlc is the higher-level component that
parses MXML files, calls asc to have it compile ActionScript, hooks up
binding, invokes the linker, and so on.</p></li>
<li><p>One of the coolest parts is swfdump. <a href="http://blogs.adobe.com/gosmith/2008/02/disassembling_a_swf_with_swfdu_1.html">As Gordon
explained,</a>
this gives you the ability to see <em>exactly</em> what is inside a swf. This is a
great learning tool for understanding what really goes on in the compiler
and in your own code. Try &ldquo;swfdump -abc myapp.swf &gt; myapp.txt&rdquo;, and then
start exploring.</p></li>
<li><p>The entire source for the command-line debugger, fdb, is all there, in
modules/debugger. For the starting point of the command-line debugger, see
DebugCLI.main(). For the entry point to the generic debugger API &ndash; upon
which both fdb and the Flex Builder debugger are built &ndash; see
Bootstrap.sessionManager().</p></li>
<li><p>In the &ldquo;development&rdquo; directory, you will find Eclipse projects for most of
the projects. There is no project there for asc, but there are projects for
mxmlc, fdb, swfutils (which has the source of swfdump), and so on. The
projects are divided into two groups: The &ldquo;java&rdquo; directory contains Eclipse
JDT projects for the Java-based parts of the Flex SDK, such as the compiler
and the debugger, and the &ldquo;flex&rdquo; directory has Flex Builder projects for
the Flex-based parts of the SDK, such as the Flex framework. To use these,
follow two steps: (1) in the preferences, in both General &gt; Workspace &gt;
Linked Resources <em>and</em> Java &gt; Build Path &gt; Classpath Variables, set
<code>FLEX_SDK</code> to point to the root directory of your SDK; (2) do File &gt;
Import, Existing Projects into Workspace.</p></li>
<li><p>Flex Builder 3 supports not only Flex 2 and Flex 3, but, in fact, it
supports any custom Flex build you care to make. Drop in your own hacked
compiler. Drop in your own hacked framework.swc. Drop in a patched
flex-config.xml, and watch projects that use that SDK automatically pick up
the changed library path. To make Flex Builder &ldquo;see&rdquo; your SDK, just go to
the Eclipse Preferences, and then Flex &gt; Installed Flex SDKs, then click
&ldquo;Add&hellip;&rdquo; and point to your SDK&rsquo;s root directory.</p></li>
<li><p>Don&rsquo;t forget that the entire <a href="http://bugs.adobe.com/flex/">Flex bug
database</a> is out there for you to see &ndash;
search for info on existing bugs, vote for bugs you want to see fixed, log
bugs, suggest enhancements.</p></li>
</ul>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Drag and drop attachments into Gmail]]></title>
    <link href="http://www.morearty.com/blog/2008/02/20/drag-and-drop-attachments-into-gmail/"/>
    <updated>2008-02-20T12:02:10-08:00</updated>
    <id>http://www.morearty.com/blog/2008/02/20/drag-and-drop-attachments-into-gmail</id>
    <content type="html"><![CDATA[<p>I use Gmail, and although I love it in general, one thing that is a little
tedious is that when you want to send someone an attachment, you can&rsquo;t drag and
drop the attachment onto your message like you can with most native email
clients &ndash; instead you have to click &ldquo;Attach a file,&rdquo; then click &ldquo;Browse,&rdquo; and
then browse to the file that you want to attach.</p>

<p>But <a href="https://addons.mozilla.org/en-US/firefox/addon/2190">dragdropupload</a> is a
slick little Firefox extension that addresses this problem.  Once you install
it, you can drag and drop any file from your computer on top of the words
&ldquo;Attach a file&rdquo; in Gmail.  Sweet!  (You can also drag and drop onto any other
website that does file upload, but Gmail is where I find it most useful.)</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Crazy Google subcategories]]></title>
    <link href="http://www.morearty.com/blog/2008/01/03/crazy-google-subcategories/"/>
    <updated>2008-01-03T01:51:28-08:00</updated>
    <id>http://www.morearty.com/blog/2008/01/03/crazy-google-subcategories</id>
    <content type="html"><![CDATA[<p>Today I typed &ldquo;wikipedia&rdquo; into Google.  Look at the weird subcategories that
showed up under the main wikipedia.org link:</p>

<p><img src="./../../../../assets/2008/01/wikipedia.gif" alt="wikipedia.gif" /></p>

<p>What the?!?</p>

<p>So of course I clicked &lsquo;em all.  &ldquo;Wikipedia:Hauptseite&rdquo; and &ldquo;Accueil&rdquo; take you
to the home pages of the German and French versions of Wikipedia, respectively.
&ldquo;Tirol&rdquo; takes you to the German-language page describing Tirol, which is
apparently &ldquo;a historical region of Western Central Europe&rdquo; (according to the
corresponding English-language page).  The last three links take you to the
English-language pages for the movie <em>Chitty Chitty Bang Bang,</em> Denzel
Washington, and commodity markets.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Flex Builder bug report: Romania is not a Socialist Republic any more!]]></title>
    <link href="http://www.morearty.com/blog/2007/10/29/flex-builder-bug-report-romania-is-not-a-socialist-republic-any-more/"/>
    <updated>2007-10-29T14:55:20-07:00</updated>
    <id>http://www.morearty.com/blog/2007/10/29/flex-builder-bug-report-romania-is-not-a-socialist-republic-any-more</id>
    <content type="html"><![CDATA[<p>This is hilarious.  Lacra, one of the Flex engineers on our team in Romania,
filed <a href="https://bugs.adobe.com/jira/browse/FB-10222">this bug</a>, which points out
a place in Flex Builder where there is a list of country codes that includes
&ldquo;Romania, Socialist Republic of (RO).&rdquo;  As she writes, &ldquo;The list of countries
in the dialog that opens mentions Romania as a socialist republic! It hasn&rsquo;t
been one in 18 years :) It is a (democratic) republic.&rdquo;</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[More Flex Builder 3.0 debugger features]]></title>
    <link href="http://www.morearty.com/blog/2007/10/23/more-flex-builder-30-debugger-features/"/>
    <updated>2007-10-23T08:26:23-07:00</updated>
    <id>http://www.morearty.com/blog/2007/10/23/more-flex-builder-30-debugger-features</id>
    <content type="html"><![CDATA[<p>I&rsquo;ve been meaning to post this ever since we released Flex Builder 3 Beta 2 a
few weeks ago. There are some nice debugger enhancements I wanted to tell you
about (in addition to the features that were in beta 1, which I described <a href="./../../../../2007/06/08/flex-builder-30-sneak-peek-debugger-tooltips/">in
June</a>).</p>

<h3>Hierarchical variables view.</h3>

<p>Reduces clutter in the Variables view by grouping all superclass members in a
separate tree node, so by default you only see the members of the current
class.</p>

<blockquote style="border-left: medium none"><a href="./../../../../assets/2007/10/inherited.png" title="inherited.png"><img src="./../../../../assets/2007/10/inherited.png" alt="inherited.png" /></a></blockquote>

<h3>Much faster single-stepping.</h3>

<p>Previously, if any variables such as &ldquo;this&rdquo; were expanded in the variables view
(so that their members were visible), then single-stepping in the debugger was
somewhat slow.  It is now much, much faster &ndash; in fact, single-stepping with
variables expanded is just as fast as single-stepping with variables collapsed.
In one quick test I just ran, single-stepping in Flex Builder 3 was <em>twenty
times faster</em> than in Flex Builder 2.  In Flex Builder 3, I can just hold down
F5, and even on a slow machine, it is executing about ten single-steps per
second.</p>

<h3>No more &ldquo;Where is the debugger&rdquo; dialog.</h3>

<p>Now when the Flash player runs a debuggable application (swf) but can&rsquo;t find a
debugger, it just runs the app, with no annoying dialog.  (If you want to force
it to prompt for a debugger, do right-click &gt; Debugger on the swf running in
the browser.)</p>

<h3>No more separate debug swf in your <code>bin</code> folder.</h3>

<p>Flex Builder 2 created YourApp.swf and YourApp-debug.swf &ndash; and also
YourApp.html and YourApp-debug.html.  Flex Builder 3 no longer creates the
<code>&quot;*-debug&quot;</code> files.  This speeds up compilation &ndash; Flex Builder only has to
create one swf &ndash; and greatly simplifies writing code that has to refer to
other swfs by filename.</p>

<p>In Flex Builder 3, the files in the &ldquo;bin&rdquo; directory are debug files. (Before we
ship, we will probably rename that folder to &ldquo;bin-debug&rdquo;.) To get the release
files, use the Export Release Version command, which creates a separate
&ldquo;bin-release&rdquo; directory. There are more details in <a href="http://www.buntel.com/blog/index.cfm/2007/10/15/The-Export-Release-Wizard">this blog
post</a>
and in <a href="http://labs.adobe.com/technologies/flex/videos/exportreleasewizard/">this
video</a>.</p>

<blockquote style="border-left: medium none"><img src="./../../../../assets/2007/10/no-debug-swf.png" alt="no-debug-swf.png" /></blockquote>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[What iWant from the iPhone: voice commands]]></title>
    <link href="http://www.morearty.com/blog/2007/07/01/what-iwant-from-the-iphone-voice-commands/"/>
    <updated>2007-07-01T09:27:56-07:00</updated>
    <id>http://www.morearty.com/blog/2007/07/01/what-iwant-from-the-iphone-voice-commands</id>
    <content type="html"><![CDATA[<p>I don&rsquo;t have an iPhone. But if I did, here&rsquo;s what I would want it to have:
voice commands, so that I can use it while driving.</p>

<p>While listening to podcasts:</p>

<ul>
<li>  &ldquo;back up&rdquo; or &ldquo;repeat&rdquo; to back up a few seconds</li>
<li>  &ldquo;pause,&rdquo; &ldquo;play,&rdquo; etc.</li>
<li>  &ldquo;faster,&rdquo; &ldquo;slower,&rdquo; &ldquo;normal speed&rdquo;</li>
</ul>

<p>Email:</p>

<ul>
<li>  iPhone reads the email to me</li>
<li>  &ldquo;next message,&rdquo; &ldquo;delete message,&rdquo; etc.</li>
<li>  Dictation, a la Dragon NaturallySpeaking. Okay, I know that&rsquo;s way too much
to ask from such a small device, but maybe someday&hellip;</li>
</ul>

<p>When using as a phone: &ldquo;call Tom&rdquo; (standard voice dialing, as some other phones
already have).</p>

<p>What else?</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Flex Builder 3 works with Eclipse 3.3]]></title>
    <link href="http://www.morearty.com/blog/2007/06/12/flex-builder-3-works-with-eclipse-33/"/>
    <updated>2007-06-12T11:05:09-07:00</updated>
    <id>http://www.morearty.com/blog/2007/06/12/flex-builder-3-works-with-eclipse-33</id>
    <content type="html"><![CDATA[<p>Hey, in case you didn&rsquo;t notice &ndash; the <a href="http://labs.adobe.com/technologies/flex/flexbuilder3/">beta of Flex Builder
3</a> works with the <a href="http://download.eclipse.org/eclipse/downloads/">beta
of Eclipse 3.3</a>.  Give it a
try!</p>

<p>Eclipse 3.3 has lots of nice new features.  One of my favorites &ndash; especially
when I am working on the Mac &ndash; is Cmd+3 (or Ctrl+3 on Windows). This gives you
full keyboard access to every menu item, command, preference, etc., just by
typing a few characters of the command.  E.g. if you want to rename something
but can&rsquo;t remember the keyboard shortcut for rename, just type Cmd+3, &ldquo;rename&rdquo;.
You&rsquo;ll be shown a list of every command that includes that word.</p>

<p>On Windows this is nice but not really a big a deal; but on Mac, it&rsquo;s awesome
for keyboard-heavy users like me.</p>

<p>(By the way, you can set up Quicksilver to do something similar for <em>all</em> apps
by following an <a href="http://www.43folders.com/2007/03/12/tme-quicksilver-application-menus/">elaborate set of
steps</a>;
but it&rsquo;s hard to figure out how to do, and the end result isn&rsquo;t quite as easy
to use as what Eclipse has done.)</p>

<p>For the full description of the feature, go to <a href="http://download.eclipse.org/eclipse/downloads/drops/S-3.3M7-200705031400/eclipse-news-M7.html">this
page</a>
and then search down for &ldquo;quick access&rdquo;.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Flex Builder 3.0 sneak peek: debugger tooltips]]></title>
    <link href="http://www.morearty.com/blog/2007/06/08/flex-builder-30-sneak-peek-debugger-tooltips/"/>
    <updated>2007-06-08T12:02:42-07:00</updated>
    <id>http://www.morearty.com/blog/2007/06/08/flex-builder-30-sneak-peek-debugger-tooltips</id>
    <content type="html"><![CDATA[<p>In a way this is a small thing, but it is certainly one of the most-requested
debugger features, and I&rsquo;m relieved that this is finally in the product:
debugger tooltips. It really should have been in Flex Builder 2.0, but it
didn&rsquo;t make it in due to time constraints.</p>

<p>So you&rsquo;re debugging:</p>

<p><a href="./../../../../assets/2007/06/1.png" title="1.png"><img src="./../../../../assets/2007/06/1.png" alt="1.png" style="border: 1px solid black" /></a></p>

<p>You want to know the value of &lsquo;i&rsquo;:</p>

<p><a href="./../../../../assets/2007/06/2.png" title="2.png"><img src="./../../../../assets/2007/06/2.png" alt="2.png" style="border: 1px solid black" /></a></p>

<p>Flex Builder is smart enough to figure out, from context, what expression you
probably wanted to see, which is often more than just the single token under
the cursor. In this example, when you hover over picDimension, Flex Builder is
smart enough to realize that what you probably actually want to see the value
of is picDimension[i], not just picDimension:</p>

<p><a href="./../../../../assets/2007/06/3.png" title="3.png"><img src="./../../../../assets/2007/06/3.png" style="border: 1px solid black" alt="3.png" /></a></p>

<p>picPos[i] is an instance of class Point:</p>

<p><a href="./../../../../assets/2007/06/4.png" title="4.png"><img src="./../../../../assets/2007/06/4.png" style="border: 1px solid black" alt="4.png" /></a></p>

<p>In the above screenshot, we didn&rsquo;t automatically show you picPos[i].y, because
there is an easy way for you to get that yourself, by hovering over the &ldquo;y&rdquo; at
the end of the expression, as shown here:</p>

<p><a href="./../../../../assets/2007/06/5.png" title="5.png"><img src="./../../../../assets/2007/06/5.png" style="border: 1px solid black" alt="5.png" /></a></p>

<p>If you hover over the &ldquo;length&rdquo; part of the expression &ldquo;gallery.photos.length&rdquo;,
we figure out from context what you are looking for &ndash; you want
gallery.photos.length, not just some global called &ldquo;length&rdquo;:</p>

<p><a href="./../../../../assets/2007/06/6.png" title="6.png"><img src="./../../../../assets/2007/06/6.png" style="border: 1px solid black" alt="6.png" /></a></p>

<p>You can select an expression and hover over it:</p>

<p><a href="./../../../../assets/2007/06/7.png" title="7.png"><img src="./../../../../assets/2007/06/7.png" style="border: 1px solid black" alt="7.png" /></a></p>

<p>Finally, in all of the above cases, if you right-click, there is a new &ldquo;Watch&rdquo;
command, to add the expression to the Expressions view.  As with the tooltip,
it figures out from the current context what expression you probably wanted to
watch:</p>

<p><a href="./../../../../assets/2007/06/8.png" title="8.png"><img src="./../../../../assets/2007/06/8.png" style="border: 1px solid black" alt="8.png" /></a></p>

<p>And in case you missed it, <a href="http://www.onflex.org">Ted</a> has been posting other
sneak peeks all week.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Debugger talk comin' up at 360Flex in Seattle]]></title>
    <link href="http://www.morearty.com/blog/2007/05/17/debugger-talk-comin-up-at-360flex-in-seattle/"/>
    <updated>2007-05-17T06:28:57-07:00</updated>
    <id>http://www.morearty.com/blog/2007/05/17/debugger-talk-comin-up-at-360flex-in-seattle</id>
    <content type="html"><![CDATA[<p>In case you haven&rsquo;t had a chance to catch it, I&rsquo;ll be giving my Flex Builder
debugger talk at <a href="http://www.360conferences.com/360flex/">360Flex</a>, August
13-15, in Seattle.  You&rsquo;ll learn a few tips on launching the debugger;
variables view mysteries explained; and so on.  Hope to see you there!</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Flex is open]]></title>
    <link href="http://www.morearty.com/blog/2007/04/26/flex-is-open/"/>
    <updated>2007-04-26T06:46:03-07:00</updated>
    <id>http://www.morearty.com/blog/2007/04/26/flex-is-open</id>
    <content type="html"><![CDATA[<p>As I&rsquo;m sure you have read by now, we have announced that <a href="http://www.adobe.com/go/opensourceflex">Flex is going open
source</a>.</p>

<p>One cool part is that not only is the Flex framework &ndash; meaning all the
ActionScript source files &ndash; open, but the Flex compiler (mxmlc and asc) and
command-line debugger (fdb) are also open.  Yes, the source of those will be
available for anyone to modify and enhance, under the same terms as the
framework (the Mozilla Public License).</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[New Flash player, and also a Flex Builder patch]]></title>
    <link href="http://www.morearty.com/blog/2007/04/16/new-flash-player-and-also-a-flex-builder-patch/"/>
    <updated>2007-04-16T17:00:29-07:00</updated>
    <id>http://www.morearty.com/blog/2007/04/16/new-flash-player-and-also-a-flex-builder-patch</id>
    <content type="html"><![CDATA[<p>Please read this if you use Flex Builder, or if you use fdb (the command-line
debugger included with the free Flex SDK):</p>

<p>There is a new Flash player, 9.0r45.  But remember: Most people out there in
the world get the &ldquo;release&rdquo; version of the player, but developers need the
deubgger version of it.</p>

<p>Get the debugger player
<a href="http://www.adobe.com/support/flashplayer/downloads.html">here</a>.  (Save that
link!  It is surprisingly hard to find, and it comes in handy each time a new
player comes out, because that&rsquo;s where you go to get debugging-enabled
players.)</p>

<p>Also, there is a patch for Flex Builder and for Flex, to make them work with
this new player.  If you are using Firefox on Windows and you don&rsquo;t have this
patch, you may get a warning message every time you try to debug.  Get that
patch <a href="http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=kb401493">here</a>.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[My debugger talk from 360Flex]]></title>
    <link href="http://www.morearty.com/blog/2007/03/22/my-debugger-talk-from-360flex/"/>
    <updated>2007-03-22T11:14:10-07:00</updated>
    <id>http://www.morearty.com/blog/2007/03/22/my-debugger-talk-from-360flex</id>
    <content type="html"><![CDATA[<p>I&rsquo;ve been meaning to post this for a while &ndash; here is the PowerPoint
presentation for the debugger talk I gave at 360Flex: <a href="./../../../../assets/2007/03/flex-builder-debugger.ppt">Flex Builder
Debugger</a></p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Common E4X pitfalls]]></title>
    <link href="http://www.morearty.com/blog/2007/03/13/common-e4x-pitfalls/"/>
    <updated>2007-03-13T10:32:54-07:00</updated>
    <id>http://www.morearty.com/blog/2007/03/13/common-e4x-pitfalls</id>
    <content type="html"><![CDATA[<p>As cool as I think E4X is, there are a few things about it that can throw you
off when you&rsquo;re getting started (they certainly took me a while to get used
to).  I thought I would pass on these tips.</p>

<h3>1. Set <code>resultFormat=&quot;e4x&quot;</code> on your HTTPService</h3>

<p>The default <code>resultFormat</code> for an <code>&lt;mx:HTTPService&gt;</code> is <code>&quot;object&quot;</code>.  When you
are retrieving XML data, <code>&quot;object&quot;</code> probably isn&rsquo;t what you want.  And you
definitely don&rsquo;t want <code>&quot;xml&quot;</code> &ndash; that is a legacy format.</p>

<p>The difference is in what comes back in the <code>lastResult</code>.  If you use the
default of <code>&quot;object&quot;</code>, then the <code>lastResult</code> is an Object with regular
ActionScript properties on it.  (Actually it&rsquo;s an ObjectProxy, but that&rsquo;s an
implementation detail.)  If you use <code>&quot;e4x&quot;</code>, then the <code>lastResult</code> is an XML
object which you can easily parse with E4X expressions.</p>

<p>So when would you want <code>&quot;object&quot;</code>?  Well, I&rsquo;m not really sure.  I always use
<code>&quot;e4x&quot;</code>.</p>

<h3>2. E4X expressions don&rsquo;t reference the topmost tag of the XML</h3>

<p>Say you have an <code>&lt;mx:HTTPService&gt;</code> called <code>myService</code>, with
<code>resultFormat=&quot;e4x&quot;</code>, and a call to it returns this document from your server:</p>
<div class="highlight"><pre><code class="xml language-xml" data-lang="xml"><span class="cp">&lt;?xml version=&quot;1.0&quot;?&gt;</span>
<span class="nt">&lt;people&gt;</span>
  <span class="nt">&lt;person&gt;</span>mike<span class="nt">&lt;/person&gt;</span>
  <span class="nt">&lt;person&gt;</span>sho<span class="nt">&lt;/person&gt;</span>
  <span class="nt">&lt;person&gt;</span>nj<span class="nt">&lt;/person&gt;</span>
<span class="nt">&lt;/people&gt;</span>
</code></pre></div>
<p>The data is now in <code>myService.lastResult</code> (or, if you are in the <code>result</code> event
handler, the data is in <code>event.result</code>.)  How do you get an XMLList for all of
the <person> elements?</p>

<p>It is a very common mistake to think that your E4X expression needs to specify
the top-level <people> tag:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="kd">var</span> <span class="n">personNodes</span><span class="p">:</span><span class="kt">XMLList</span> <span class="o">=</span> <span class="n">myService</span><span class="o">.</span><span class="na">lastResult</span><span class="o">.</span><span class="na">people</span><span class="o">.</span><span class="na">person</span><span class="o">;</span> <span class="c1">// wrong</span>
</code></pre></div>
<p>That doesn&rsquo;t work.  You should think of the <code>myService.lastResult</code> as being
synonymous with the top-level node.  So the way you get a list of the <person>
nodes is:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="kd">var</span> <span class="n">personNodes</span><span class="p">:</span><span class="kt">XMLList</span> <span class="o">=</span> <span class="n">myService</span><span class="o">.</span><span class="na">lastResult</span><span class="o">.</span><span class="na">person</span><span class="o">;</span> <span class="c1">// right</span>
</code></pre></div>
<h3>3. Use <code>for each</code>, not <code>for</code></h3>

<p>ECMAScript has had <code>for (key in collection)</code> for a long time.  But notice that
when you use this form of the <code>for</code> loop, the looping variable is the <em>key</em>
into the collection, not the <em>value</em> of an entry in the collection.  Thus,
inside the loop you would typically write <code>collection[key]</code> to refer to the
value.</p>

<p>E4X adds an additional syntax to the language (which can actually be used on
any collection, not just E4X expressions): <code>for each (value in collection)</code>.  I
suspect they did this because using a <code>for</code> loop is rather painful and
inefficient &ndash; who wants to write code like this?</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="k">for</span> <span class="o">(</span><span class="n">var</span> <span class="n">key</span><span class="o">:*</span> <span class="k">in</span> <span class="n">myService</span><span class="o">.</span><span class="na">lastResult</span><span class="o">.</span><span class="na">person</span><span class="o">)</span>
<span class="o">{</span>
  <span class="c1">// Since we used &#39;for&#39; instead of &#39;for each&#39;, we now</span>
  <span class="c1">// have to write this ridiculous and inefficient code:</span>
  <span class="n">var</span> <span class="n">value</span><span class="o">:*</span> <span class="o">=</span> <span class="n">myService</span><span class="o">.</span><span class="na">lastResult</span><span class="o">.</span><span class="na">person</span><span class="o">[</span><span class="n">key</span><span class="o">];</span>
  <span class="o">...</span>
<span class="o">}</span>
</code></pre></div>
<p>So when writing E4X code, you almost always use <code>for each</code>:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="k">for</span> <span class="k">each</span> <span class="o">(</span><span class="n">var</span> <span class="n">value</span><span class="o">:*</span> <span class="k">in</span> <span class="n">myService</span><span class="o">.</span><span class="na">lastResult</span><span class="o">.</span><span class="na">person</span><span class="o">)</span>
<span class="o">{</span>
  <span class="o">...</span>
<span class="o">}</span>
</code></pre></div>
<p>The only thing I wish was different was, it took me a long time to memorize
that &ldquo;for&rdquo; gets keys and &ldquo;for each&rdquo; gets values.  In general I am pretty good
at keeping track of lots of little details, but with so many different
variations on foreach keywords in all the languages I use from time to time &ndash;
ECMAScript, Java, C#, PHP, Bourne shell, C shell, etc. &ndash; I always find it hard
to remember the foreach syntax for any given language, and the added complexity
of having two collection-looping syntaxes in ActionScript is almost more than
my little brain can bear.  I wish there was <code>for keys (var k:* in collection)</code>
and <code>for values (var v:* in collection)</code> or something like that.</p>

<h3>4. Use <code>for each (child in parent.*)</code>, not <code>for each (child in parent)</code></h3>

<p>Say you have this document:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="kd">var</span> <span class="n">mydocument</span><span class="p">:</span><span class="kt">XML</span> <span class="o">=</span>
  <span class="o">&lt;</span><span class="n">root</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">cat</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">mouse</span> <span class="o">/&gt;</span>
      <span class="o">&lt;</span><span class="n">mouse</span> <span class="o">/&gt;</span>
      <span class="o">&lt;</span><span class="n">mouse</span> <span class="o">/&gt;</span>
    <span class="o">&lt;/</span><span class="n">cat</span><span class="o">&gt;</span>
  <span class="o">&lt;/</span><span class="n">root</span><span class="o">&gt;</span>
<span class="kd">var</span> <span class="n">cats</span><span class="p">:</span><span class="kt">XMLList</span> <span class="o">=</span> <span class="n">mydocument</span><span class="o">.</span><span class="na">cat</span><span class="o">;</span> <span class="c1">// returns list with one entry</span>
</code></pre></div>
<p>You now want to iterate over all the mice that are inside those cats.</p>

<p>Well, for getting the properties of a regular ActionScript object, you write
code like this:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="kd">var</span> <span class="n">o</span><span class="p">:</span><span class="kt">Object</span> <span class="o">=</span> <span class="o">...;</span>
<span class="k">for</span> <span class="k">each</span> <span class="o">(</span><span class="n">var</span> <span class="n">property</span><span class="o">:*</span> <span class="k">in</span> <span class="n">o</span><span class="o">)</span> <span class="o">...</span>
</code></pre></div>
<p>So you might think that you do the same thing here:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="k">for</span> <span class="k">each</span> <span class="o">(</span><span class="kd">var</span> <span class="n">mouse</span><span class="p">:</span><span class="kt">XML</span> <span class="k">in</span> <span class="n">cats</span><span class="o">)</span> <span class="o">...</span> <span class="c1">// wrong</span>
</code></pre></div>
<p>Alas, E4X is different.  In E4X, &ldquo;cats&rdquo; is actually a collection &ndash; a list of
all the <cat> nodes (remember, &ldquo;cats&rdquo; is an XMLList, with just one entry in
this example), and when you iterate over &ldquo;cats&rdquo;, that means you want to get one
<cat> each time through the loop.</p>

<p>To fix this, you instead use an E4X expression that specifies exactly which
child nodes of the <cat> you want:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="c1">// iterate over all immediate children</span>
<span class="k">for</span> <span class="k">each</span> <span class="o">(</span><span class="kd">var</span> <span class="n">mouse</span><span class="p">:</span><span class="kt">XML</span> <span class="k">in</span> <span class="n">cats</span><span class="o">.*)</span> <span class="o">{</span> <span class="o">...</span> <span class="o">}</span>

<span class="c1">// or if you prefer: iterate over only those immediate</span>
<span class="c1">// children that are &lt;mouse&gt; nodes</span>
<span class="k">for</span> <span class="k">each</span> <span class="o">(</span><span class="kd">var</span> <span class="n">mouse</span><span class="p">:</span><span class="kt">XML</span> <span class="k">in</span> <span class="n">cats</span><span class="o">.</span><span class="na">mouse</span><span class="o">)</span> <span class="o">{</span> <span class="o">...</span> <span class="o">}</span>
</code></pre></div>
<h3>5. E4X intentionally blurs the distinction between XML and XMLList</h3>

<p>When you begin to learn E4X, you learn that there are two main data types,
<code>XML</code> and <code>XMLList</code>.  That seems simple enough.  But then after a while, you
start to notice places where it seems like the &ldquo;wrong&rdquo; type is being used, or
where impossible things are happening.</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="n">var</span> <span class="n">mydocument</span> <span class="o">=</span>
  <span class="o">&lt;</span><span class="n">root</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">rabbit</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;Brownster Johansson McGee&quot;</span> <span class="o">/&gt;</span>
  <span class="o">&lt;/</span><span class="n">root</span><span class="o">&gt;;</span>

<span class="c1">// &#39;mydocument.rabbit&#39; means to get a list of ALL &lt;rabbit&gt;</span>
<span class="c1">// nodes, so myPetRabbit must be an XMLList, right?  But</span>
<span class="c1">// I&#39;ll call my variable &#39;myPetRabbit&#39;, not &#39;myPetRabbits&#39;,</span>
<span class="c1">// because I happen to know that I have only one pet</span>
<span class="c1">// rabbit.</span>
<span class="kd">var</span> <span class="n">myPetRabbit</span><span class="p">:</span><span class="kt">XMLList</span> <span class="o">=</span> <span class="n">mydocument</span><span class="o">.</span><span class="na">rabbit</span><span class="o">;</span>

<span class="c1">// What&#39;s her name?  Hey wait a minute, &quot;her&quot; name?</span>
<span class="c1">// Why does this next line work?  Isn&#39;t myPetRabbit an XMLList?</span>
<span class="c1">// What does it mean to get an attribute of a list??</span>
<span class="nf">trace</span><span class="o">(</span><span class="n">myPetRabbit</span><span class="o">.</span><span class="err">@</span><span class="n">name</span><span class="o">);</span>
</code></pre></div>
<p>The reason this works is that E4X intentionally blurs the distinction between
<code>XML</code> and <code>XMLList</code>.  Any <code>XMLList</code> that contains exactly one element can be
treated as if it were an <code>XML</code>.  (Furthermore, in this example, even if
&lsquo;myPetRabbit&rsquo; held a list of more than one node, <code>myPetRabbit.@name</code> is still a
legal expression; it simply returns a list of all &ldquo;name&rdquo; attribute nodes of all
of those <rabbit> elements.)</p>

<p>In fact, if you search the <a href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-357.pdf">E4X
spec</a>
(PDF) for &ldquo;blur&rdquo;, you will find 15 usages of the phrase &ldquo;&hellip; intentionally
blurs the distinction between&hellip;.&rdquo;</p>

<p>For example, another place where this blurring is evident is in the behavior of
<code>XMLList.toString()</code>.  As the Flex docs say:</p>

<ul>
<li>  If the XML object has simple content, toString() returns the string
contents of the XML object with the following stripped out: the start tag,
attributes, namespace declarations, and end tag.</li>
<li>  If the XML object has complex content, toString() returns an XML encoded
string representing the entire XML object, including the start tag,
attributes, namespace declarations, and end tag.</li>
</ul>

<p>So if an XMLList contains <code>&lt;node&gt;hello&lt;/node&gt;</code>, then <code>toString()</code> will return
<code>&quot;hello&quot;</code>; but if the list contains <code>&lt;node&gt;hello&lt;/node&gt;&lt;node&gt;goodbye&lt;/node&gt;</code>,
then <code>toString()</code> will return <code>&quot;&lt;node&gt;hello&lt;/node&gt;&lt;node&gt;goodbye&lt;/node&gt;&quot;</code> (not
<code>&quot;hellogoodbye&quot;</code>).  Presumably this decision was made in an effort to achieve
&ldquo;do what I mean&rdquo; behavior, where the output would match what developers most
often intended; but personally I find it a little confusing.  If you really
need the full XML version of an XMLList that contains simple content, use
<code>toXMLString()</code> instead of <code>toString()</code>.</p>

<h3>6. Warning, a simple-looking expression can be expensive</h3>

<p>When you are working with ordinary Objects, there is nothing wrong with writing
code like this:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="kd">var</span> <span class="n">x</span><span class="p">:</span><span class="kt">Object</span> <span class="o">=</span> <span class="o">...;</span>
<span class="k">if</span> <span class="o">(</span><span class="n">x</span><span class="o">.</span><span class="na">y</span><span class="o">.</span><span class="na">z</span> <span class="o">==</span> <span class="mi">3</span><span class="o">)</span>
  <span class="n">foo</span><span class="o">(</span><span class="n">x</span><span class="o">.</span><span class="na">y</span><span class="o">.</span><span class="na">z</span><span class="o">);</span>
</code></pre></div>
<p>That code will usually run very fast.  The only possible problem is if &ldquo;y&rdquo; or
&ldquo;z&rdquo; is actually a getter with a slow implementation, but that doesn&rsquo;t happen
too often.</p>

<p>But with E4X, it is much more likely that repeating an expression such as
&ldquo;x.y.z&rdquo; will mean that an expensive lookup operation has to be done a second
time:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="kd">var</span> <span class="n">mydocument</span><span class="p">:</span><span class="kt">XML</span> <span class="o">=</span> <span class="o">...;</span>
<span class="k">if</span> <span class="o">(</span><span class="n">mydocument</span><span class="o">.</span><span class="na">cat</span><span class="o">.</span><span class="na">mouse</span><span class="o">.</span><span class="na">length</span><span class="o">()</span> <span class="o">==</span> <span class="mi">3</span><span class="o">)</span>
  <span class="n">foo</span><span class="o">(</span><span class="n">mydocument</span><span class="o">.</span><span class="na">cat</span><span class="o">.</span><span class="na">mouse</span><span class="o">);</span>
</code></pre></div>
<p>This looks very similar to the plain-Object example, but the difference is that
&ldquo;mydocument.cat.mouse&rdquo; is actually executing a whole lot of code behind the
scenes.  It has to walk through your XML structures, figure out which XML nodes
match the given expression, and then create a new XMLList containing only those
nodes.</p>

<p>So if you need to re-use the result of an E4X expression, you will usually want
to save it in a temporary variable:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="kd">var</span> <span class="n">mydocument</span><span class="p">:</span><span class="kt">XML</span> <span class="o">=</span> <span class="o">...;</span>
<span class="kd">var</span> <span class="n">mice</span><span class="p">:</span><span class="kt">XMLList</span> <span class="o">=</span> <span class="n">mydocument</span><span class="o">.</span><span class="na">cat</span><span class="o">.</span><span class="na">mouse</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="n">mice</span><span class="o">.</span><span class="na">length</span><span class="o">()</span> <span class="o">==</span> <span class="mi">3</span><span class="o">)</span>
  <span class="n">foo</span><span class="o">(</span><span class="n">mice</span><span class="o">);</span>
</code></pre></div>
<h3>The debugger can help</h3>

<p>If you debug your app, the Variables will can help you see what values have
been assigned to your XML and XMLList variables.  The main pane of the
Variables view shows a hierarchical view of the XML variable, and the detail
pane shows the full XML text:</p>

<p><img id="image74" src="./../../../../assets/2007/03/xmlvars.png" alt="XML variables" /></p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Macros that are available in html-template files]]></title>
    <link href="http://www.morearty.com/blog/2007/01/24/macros-that-are-available-in-html-template-files/"/>
    <updated>2007-01-24T10:51:53-08:00</updated>
    <id>http://www.morearty.com/blog/2007/01/24/macros-that-are-available-in-html-template-files</id>
    <content type="html"><![CDATA[<style>
dd {
  margin-left: 5em;
}
</style>

<p>In a <a href="./../../../../2006/12/11/changing-the-filenames-in-flex-builder-html-templates/">post last
month</a>,
I briefly mentioned the list of macro substitutions that are available in the
files in the <code>html-template</code> folder.  Here, I&rsquo;ll offer a little more
information on those.  I&rsquo;ll try to make sure this makes it into the next
version of the documentation.</p>

<dl>
<dt><code>${project}</code></dt>
<dd>The name of the project, e.g. <code>MyProject</code>.</dd>
<dt><code>${application}</code></dt>
<dd>The name of the application, e.g. <code>MyApp</code>.</dd>
<dt><code>${version_major}</code></dt>
<dd>The major version number of the version of Flash that is required to run
this app, e.g. <code>9</code> for version 9.0 r28.  You can change this and the
other <code>${version_...}</code> macros by going to Project > Properties, then
&ldquo;Flex Compiler&rdquo; or &ldquo;ActionScript Compiler,&rdquo; and then changing the player
version number in the &ldquo;HTML wrapper&rdquo; section.</dd>
<dt><code>${version_minor}</code></dt>
<dd>The minor version number of the version of Flash that is required to run
this app, e.g. <code>0</code> for version 9.0 r28.</dd>
<dt><code>${version_revision}</code></dt>
<dd>The revision number of the version of Flash that is required to run this app, e.g. <code>28</code> for version 9.0 r28.</dd>
<dt><code>${build_suffix}</code></dt>
<dd>This is equal to <code>"-debug"</code> when building the debug version of
the SWF, and <code>""</code> when building the release version.</dd>
<dt><code>${swf}</code></dt>
<dd>The name of the SWF, not including the <code>.swf</code> extension, e.g.
<code>MyApp</code> or <code>MyApp-debug</code>. This is essentially a
convenience macro which is equivalent to
<code>${application}${build_suffix}</code>.</dd>
<dt><code>${bgcolor}</code></dt>
<dd>The background color of the application, as specified in the
<code>backgroundColor</code> attribute of the
<code>&lt;mx:Application&gt;</code> tag, or, in the case of ActionScript-only
projects, in the <code>backgroundColor</code> field of the <code>[SWF]</code>
metadata attribute of the main application class, e.g.
<code>[SWF(backgroundColor="#ffffff")] public class MyApp extends Sprite</code>
(see <a href="./../../../../2006/06/27/setting-the-width-and-height-of-a-pure-actionscript-application/">this post</a>
for more information on setting the width, height, and background color of an
ActionScript project). The result is in the form <code>#rrggbb</code>, e.g.
<code>#ffffff</code>. This can actually be a little tricky to use, because by
default, the background of a Flex app is actually a gentle gradient from one
color to another; if you want the HTML background to match the background of
your Flex app, you may need to fiddle with both the
<code>backgroundColor</code> and <code>backgroundGradientColors</code>
attributes of the <code>&lt;mx:Application&gt;</code> tag.</dd>
<dt><code>${width}</code></dt>
<dd>The width of the application, as specified in the <code>width</code>
attribute of the <code>&lt;mx:Application&gt;</code> tag, or, in the case of
ActionScript-only projects, in the <code>width</code> field of the
<code>[SWF]</code> metadata attribute of the main application class, e.g.
<code>[SWF(width="300", height="400")] public class MyApp extends
Sprite</code>.</dd>
<dt><code>${height}</code></dt>
<dd>The height of the application, as specified in the <code>height</code>
attribute of the <code>&lt;mx:Application&gt;</code> tag, or, in the case of
ActionScript-only projects, in the <code>height</code> field of the
<code>[SWF]</code> metadata attribute of the main application class, e.g.
<code>[SWF(width="300", height="400")] public class MyApp extends
Sprite</code>.</dd>
<dt><code>${title}</code></dt>
<dd>The title of the application, as specified in the <code>pageTitle</code>
attribute of the <code>&lt;mx:Application&gt;</code> tag, or, in the case of
ActionScript-only projects, in the <code>pageTitle</code> field of the
<code>[SWF]</code> metadata attribute of the main application class, e.g.
<code>[SWF(pageTitle="flex r00lz")] public class MyApp extends
Sprite</code>.</dd>
</dl>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Meet me at "Meet the Flex Team"]]></title>
    <link href="http://www.morearty.com/blog/2007/01/15/meet-me-at-meet-the-flex-team/"/>
    <updated>2007-01-15T10:09:21-08:00</updated>
    <id>http://www.morearty.com/blog/2007/01/15/meet-me-at-meet-the-flex-team</id>
    <content type="html"><![CDATA[<p>Meet me and many other Flex/Flex Builder team members at <a href="http://www.onflex.org/ted/2007/01/meet-flex-team-in-san-francisco.php">&ldquo;Meet the Flex
Team&rdquo;</a>
on Thursday, January 25th, at the San Francisco office of Adobe.  See our very
cool building, with lots of exposed wood beams and brick walls; and tell me
that debugger feature you desperately need.  (Seriously &ndash; I want to hear
requests.)</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Solution to quiz #1: inner functions and garbage collection]]></title>
    <link href="http://www.morearty.com/blog/2007/01/10/solution-to-quiz-1-inner-functions-and-garbage-collection/"/>
    <updated>2007-01-10T14:47:58-08:00</updated>
    <id>http://www.morearty.com/blog/2007/01/10/solution-to-quiz-1-inner-functions-and-garbage-collection</id>
    <content type="html"><![CDATA[<p>Yesterday I posted a
<a href="./../../../../2007/01/08/quiz-1-find-the-bug/">quiz</a> with a bit
of code that has a bug.  Here&rsquo;s the solution.</p>

<p>The interesting thing about challenging readers to find a bug is that they will
inevitably point out things that hadn&rsquo;t occurred to me.  I&rsquo;ll discuss each of
those.</p>

<p>Here&rsquo;s the code again:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="kd">package</span> <span class="o">{</span>
    <span class="k">import</span> <span class="nn">flash.display.Sprite</span><span class="o">;</span>
    <span class="k">import</span> <span class="nn">flash.events.Event</span><span class="o">;</span>

    <span class="kd">public</span> <span class="kd">class</span> <span class="n">MyClass</span> <span class="kd">extends</span> <span class="n">Sprite</span>
    <span class="o">{</span>
        <span class="kd">public</span> <span class="kd">function </span><span class="nf">MyClass</span><span class="o">()</span>
        <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="na">addEventListener</span><span class="o">(</span><span class="n">Event</span><span class="o">.</span><span class="na">ENTER_FRAME</span><span class="o">,</span>
                <span class="kd">function</span><span class="o">(</span><span class="n">e</span><span class="o">:</span><span class="n">Event</span><span class="o">):</span><span class="kc">void</span> <span class="o">{</span> <span class="nf">trace</span><span class="o">(</span><span class="s2">&quot;enter frame&quot;</span><span class="o">)</span> <span class="o">},</span>
                <span class="kc">false</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">}</span>
</code></pre></div>
<p>Two readers had the answer I was looking for: The callback function is an inner
function rather than a member function, but we passed &ldquo;true&rdquo; for the
&ldquo;useWeakReference&rdquo; parameter of addEventListener().</p>

<p>When you pass a regular method to addEventListener(), that method always has a
specific &ldquo;this&rdquo; object associated with it &ndash; the object that was &ldquo;this&rdquo; at the
point where the reference to the method was created.  But when you pass an
inner function, inner functions do not have a specific associated &ldquo;this&rdquo;
object.  So unless you created some other sort of reference to the function,
e.g. by assigning it to a member variable of an object or something, it will
just disappear when garbage collection takes place.</p>

<p>As for other answers: Two readers guessed that the bug was that I was listening
for the <code>ENTER_FRAME</code> event, but Sprite doesn&rsquo;t have a timeline (if you want a
timeline, you should extend MovieClip), so it wouldn&rsquo;t work.  I actually don&rsquo;t
know a lot about that part of Flash, but I checked the docs, and it looks like
the <code>ENTER_FRAME</code> (aka <code>enterFrame</code>) event is part of class DisplayObject,
which is not a MovieClip; the docs say, &ldquo;Dispatched when the playhead is
entering a new frame. If the playhead is not moving, or if there is only one
frame, this event is dispatched continuously in conjunction with the frame
rate.&rdquo; The implication there is that you don&rsquo;t have to have your own timeline
in order to listen for frame events. Perhaps you are listening to the playhead
of the timeline that contains you? Or maybe no specific timeline is involved &ndash;
maybe it just means the player has moved to its next frame.</p>

<p>Finally, another reader suggested that since the listener is created inline, it
will never be possible to remove it, because there is no way to refer to it.
That is certainly true, and I guess it could be considered a bug in some cases,
but it isn&rsquo;t a bug in the sense I was thinking of.  For many programs, it is
common usage to add event listeners using inner functions, because the program
has no expectation of ever needing to remove those listeners.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Quiz #1: Find the bug]]></title>
    <link href="http://www.morearty.com/blog/2007/01/08/quiz-1-find-the-bug/"/>
    <updated>2007-01-08T16:00:32-08:00</updated>
    <id>http://www.morearty.com/blog/2007/01/08/quiz-1-find-the-bug</id>
    <content type="html"><![CDATA[<p>Where is the bug in this program?  It seems to run just fine.  But there is a
bug.  Can you find it?</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="kd">package</span> <span class="o">{</span>
    <span class="k">import</span> <span class="nn">flash.display.Sprite</span><span class="o">;</span>
    <span class="k">import</span> <span class="nn">flash.events.Event</span><span class="o">;</span>

    <span class="kd">public</span> <span class="kd">class</span> <span class="n">MyClass</span> <span class="kd">extends</span> <span class="n">Sprite</span>
    <span class="o">{</span>
        <span class="kd">public</span> <span class="kd">function </span><span class="nf">MyClass</span><span class="o">()</span>
        <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="na">addEventListener</span><span class="o">(</span><span class="n">Event</span><span class="o">.</span><span class="na">ENTER_FRAME</span><span class="o">,</span>
                <span class="kd">function</span><span class="o">(</span><span class="n">e</span><span class="o">:</span><span class="n">Event</span><span class="o">):</span><span class="kc">void</span> <span class="o">{</span> <span class="nf">trace</span><span class="o">(</span><span class="s2">&quot;enter frame&quot;</span><span class="o">)</span> <span class="o">},</span>
                <span class="kc">false</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">}</span>
</code></pre></div>]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Beginner videos: Flex Builder debugger]]></title>
    <link href="http://www.morearty.com/blog/2007/01/03/beginner-videos-flex-builder-debugger/"/>
    <updated>2007-01-03T12:07:32-08:00</updated>
    <id>http://www.morearty.com/blog/2007/01/03/beginner-videos-flex-builder-debugger</id>
    <content type="html"><![CDATA[<p>Lynda.com has posted some
<a href="http://movielibrary.lynda.com/html/modPage.asp?ID=290">videos</a> that introduce
the basic functionality of the Flex Builder debugger.  If you are new to
debuggers, you may find them informative.  And even if you are an experienced
user, the last free video in the series shows how <code>&lt;mx:TraceTarget/&gt;</code> can
sometimes be helpful for watching the network traffic between your Flex app and
a server.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Stellarium: Super-cool free astronomy program]]></title>
    <link href="http://www.morearty.com/blog/2006/12/24/stellarium-super-cool-free-astronomy-program/"/>
    <updated>2006-12-24T00:16:05-08:00</updated>
    <id>http://www.morearty.com/blog/2006/12/24/stellarium-super-cool-free-astronomy-program</id>
    <content type="html"><![CDATA[<p>An uncle of mine has recently gotten interested in astronomy, so I was looking
for an astro-related Christmas present for him, and I found an extremely cool
program, which also turns out to be free (and open-source):
<a href="http://www.stellarium.org">Stellarium</a>.</p>

<p>When you run it, it displays a full-screen rendering of the sky, and in a very
cool and realistic way: In the foreground you can see the ground, e.g. grass,
trees, etc.; and the sky is beautifully rendered with colors appropriate to the
current time of day where you are, e.g. dark blue with a pink horizon at sunset
(the sky is always beautiful in Stellarium-land; be sure to check out the
screenshots on the website).</p>

<p>But hey, you want to see what stars <em>would</em> be visible if it weren&rsquo;t daytime?
Click a button, and the atmosphere disappears.  You want to see what stars are
currently hidden below the horizon?  Click another button, and the ground
disappears.  You want to see the sun and stars move in fast motion?  Want to
see how the sky looked in 1966 during the heaviest meteor shower ever seen?
Want help learning where the constellations are?  Where the planets are?  Click
click click.  Want to see close-up photos of all the planets?  Of a number of
interesting nebulae?  They&rsquo;re all there.  Want to see how high the sun is right
now in Alaska?  Change your location to Alaska.  Want to see how the sun never
sets when it&rsquo;s summer at one of the poles?  Change your location, and
accelerate time, and watch the sun move across the sky without setting.</p>

<p>When you start the program, it defaults to a viewpoint from Paris; to change
that, click configuration (the wrench icon at the bottom of the screen), go to
Location, and click the map.  Also, to zoom in on your general area so it&rsquo;s
easier to click the right spot, hold the mouse over your part of the world and
rotate the mouse wheel.</p>

<p>I&rsquo;ve burned it onto a CD, and I&rsquo;m going to give it to my uncle.  Yes it&rsquo;s free,
but he never would have found it on his own, and also I&rsquo;m gonna give him a hand
with it since he is only moderately computer-savvy.</p>

<p>Merry Christmas!</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Changing the filenames in Flex Builder html templates]]></title>
    <link href="http://www.morearty.com/blog/2006/12/11/changing-the-filenames-in-flex-builder-html-templates/"/>
    <updated>2006-12-11T12:36:58-08:00</updated>
    <id>http://www.morearty.com/blog/2006/12/11/changing-the-filenames-in-flex-builder-html-templates</id>
    <content type="html"><![CDATA[<p>Suppose you want the main HTML file that wraps your Flash app to be deployed as
<code>index.aspx</code> instead of <code>index.html</code>.  It&rsquo;s a little trickier than you might
think.</p>

<p>If you look in the <code>html-template</code> directory of your project, you will see that
the main file is called <code>index.template.html</code>.  This is a special name &ndash; Flex
Builder recognizes filenameit, and says &ldquo;Oh I know what that is,&rdquo; and uses it
to create <code>MyApp.html</code> and <code>MyApp-debug.html</code> in the <code>bin</code> folder.</p>

<p>But if you just rename it to <code>index.template.aspx</code>, you&rsquo;ll have problems.
Notice that after doing that, and then cleaning your project, you now have only
<code>index.aspx</code> in the <code>bin</code> folder.  There are two issues with that: For one
thing, the app name isn&rsquo;t part of the , which cause trouble if you have more
than one app in the project; and also, it doesn&rsquo;t differentiate between the
debug and release versions of the file.  If you examine it, you&rsquo;ll see that it
contains a reference to <code>MyApp-debug.swf</code>.  Where did the release one go?</p>

<p>The answer is that since the file no longer has the special
<code>index.template.html</code> name, Flex Builder doesn&rsquo;t know what to do with it.  It
does see the &ldquo;.template&rdquo; part of the name, and it uses that to decide that it
should do macro-substutition within the file; but beyond that, it does nothing
more.</p>

<p>And since there are two SWFs (release and debug), Flex Builder ends up
processing your file twice.  First, it creates the release version of
<code>index.aspx</code>, then it creates the debug version of the same file, overwriting
the release version.  (It probably should report an error in this case, but it
doesn&rsquo;t.)</p>

<p>But the solution, it turns out, is very easy (although not at all obvious):
Give the file the rather cryptic name of&hellip;</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">${application}${build_suffix}.template.aspx
</code></pre></div>
<p>That does the trick.  The <code>${application}</code> and <code>${build_suffix}</code> macros are
substituted when creating the filename that goes into the <code>bin</code> directory
(build_suffix is &ldquo;&rdquo; for the release build and &ldquo;-debug&rdquo; for the debug build);
and &ldquo;.template&rdquo; causes Flex Builder to do macro substitution inside the file.</p>

<p>To wrap up:</p>

<ul>
<li>  Any file in the html-template directory can have macros in the filename.
Substitution will be performed when using those template files to the
create the files in the <code>bin</code> directory.</li>
<li>  In addition, if any filename contains <code>.template</code> (either at the very end,
or followed by a punctuation character such as &ldquo;.&rdquo;), then the <em>contents</em> of
that file will have macro substitution performed, and the <code>.template</code> part
will be removed from the filename when copying to the <code>bin</code> directory.</li>
<li>  Finally, the name <code>index.template.html</code> is a special case, and is
essentially equivalent to <code>${application}${build_suffix}.template.html</code>.</li>
</ul>

<p>So, what macros are available?  <code>${project}</code>, <code>${application}</code>,
<code>${version_major}</code>, <code>${version_minor}</code>, <code>${version_revision}</code>,
<code>${build_suffix}</code>, <code>${swf}</code>, <code>${bgcolor}</code>, <code>${width}</code>, <code>${height}</code>, <code>${title}</code>.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[E4X tip: writing expressions to test attributes that may not exist]]></title>
    <link href="http://www.morearty.com/blog/2006/11/01/e4x-tip-and-quiz-writing-expressions-to-test-attributes-that-may-not-exist/"/>
    <updated>2006-11-01T23:40:19-08:00</updated>
    <id>http://www.morearty.com/blog/2006/11/01/e4x-tip-and-quiz-writing-expressions-to-test-attributes-that-may-not-exist</id>
    <content type="html"><![CDATA[<p>E4X is an awesome way to work with XML.  But one common pitfall is trying to
write an expression that tests the value of a particular attribute, when some of
the XML nodes may not even have that attribute.</p>

<p>For example, let&rsquo;s say you have this XML in a variable called <code>albums</code>:</p>
<div class="highlight"><pre><code class="actionscript language-actionscript" data-lang="actionscript"><span class="k">var</span> <span class="nx">albums</span><span class="o">:</span><span class="nb">XML</span> <span class="o">=</span>
<span class="o">&lt;</span><span class="nx">albums</span><span class="o">&gt;</span>
  <span class="o">&lt;</span><span class="nx">album</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;The Dark Side of the Moon&quot;</span> <span class="nx">artist</span><span class="o">=</span><span class="s2">&quot;Pink Floyd&quot;</span> <span class="nx">year</span><span class="o">=</span><span class="s2">&quot;1973&quot;</span> <span class="o">/&gt;</span>
  <span class="o">&lt;</span><span class="nx">album</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;Rubber Soul&quot;</span> <span class="nx">artist</span><span class="o">=</span><span class="s2">&quot;The Beatles&quot;</span> <span class="nx">year</span><span class="o">=</span><span class="s2">&quot;1965&quot;</span> <span class="o">/&gt;</span>
<span class="o">&lt;/</span><span class="nx">albums</span><span class="o">&gt;</span>
</code></pre></div>
<p>It&rsquo;s easy to write an expression to get all albums that were released in the 1970s:</p>
<div class="highlight"><pre><code class="actionscript language-actionscript" data-lang="actionscript"><span class="k">var</span> <span class="nx">seventiesAlbums</span><span class="o">:</span><span class="nb">XMLList</span> <span class="o">=</span> <span class="nx">albums</span><span class="p">.</span><span class="nx">album</span><span class="p">.(</span><span class="err">@</span><span class="nx">year</span> <span class="o">&gt;=</span> <span class="mi">1970</span> <span class="o">&amp;&amp;</span> <span class="err">@</span><span class="nx">year</span> <span class="o">&lt;=</span> <span class="mi">1979</span><span class="p">);</span>
</code></pre></div>
<p>But let&rsquo;s say some of the XML nodes you are testing don&rsquo;t have a &ldquo;year&rdquo; attribute:</p>
<div class="highlight"><pre><code class="actionscript language-actionscript" data-lang="actionscript"><span class="k">var</span> <span class="nx">albums</span><span class="o">:</span><span class="nb">XML</span> <span class="o">=</span>
<span class="o">&lt;</span><span class="nx">albums</span><span class="o">&gt;</span>
  <span class="o">&lt;</span><span class="nx">album</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;The Dark Side of the Moon&quot;</span> <span class="nx">artist</span><span class="o">=</span><span class="s2">&quot;Pink Floyd&quot;</span> <span class="nx">year</span><span class="o">=</span><span class="s2">&quot;1973&quot;</span> <span class="o">/&gt;</span>
  <span class="o">&lt;</span><span class="nx">album</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;Rubber Soul&quot;</span> <span class="nx">artist</span><span class="o">=</span><span class="s2">&quot;The Beatles&quot;</span> <span class="nx">year</span><span class="o">=</span><span class="s2">&quot;1965&quot;</span> <span class="o">/&gt;</span>
  <span class="o">&lt;</span><span class="nx">album</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;Haunted&quot;</span> <span class="nx">artist</span><span class="o">=</span><span class="s2">&quot;Poe&quot;</span> <span class="o">/&gt;</span>
<span class="o">&lt;/</span><span class="nx">albums</span><span class="o">&gt;</span>
</code></pre></div>
<p>In that case, unfortunately the conditional-test part of the above E4X
expression, <code>(@year &gt;= 1970 &amp;&amp; @year &lt;= 1979)</code>, will throw an
exception:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">ReferenceError: Error #1065: Variable @year is not defined.
</code></pre></div>
<p>So, what to do?  I&rsquo;ve seen various complicated solutions to this problem; but to
me the cleanest one is to replace <code>@year</code> with <code>attribute(&quot;year&quot;)</code>
&ndash; do this for any attribute that you don&rsquo;t know for sure will be present:</p>
<div class="highlight"><pre><code class="actionscript language-actionscript" data-lang="actionscript"><span class="k">var</span> <span class="nx">seventiesAlbums</span><span class="o">:</span><span class="nb">XMLList</span> <span class="o">=</span> <span class="nx">albums</span><span class="p">.</span><span class="nx">album</span><span class="p">.(</span><span class="nx">attribute</span><span class="p">(</span><span class="s2">&quot;year&quot;</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="mi">1970</span> <span class="o">&amp;&amp;</span>
    <span class="nx">attribute</span><span class="p">(</span><span class="s2">&quot;year&quot;</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="mi">1979</span><span class="p">);</span>
</code></pre></div>
<p>True, this is more verbose and slightly uglier; but it&rsquo;s not too bad.</p>

<p>The reason this works is that the function <a
href="http://livedocs.macromedia.com/flex/2/langref/XML.html#attribute()"><tt>XML.attribute()</tt></a>
is documented as returning an empty <code>XMLList</code> when the attribute you request
does not exist.  But when you just say <code>@year</code>, that&rsquo;s like saying &ldquo;trace(blah)&rdquo;
where blah is some variable that does not exist &ndash; the player tries to find
something called <code>@year</code>, and it can&rsquo;t, so it complains.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Correction to the time of my talk at MAX]]></title>
    <link href="http://www.morearty.com/blog/2006/10/24/correction-to-the-time-of-my-talk-at-max/"/>
    <updated>2006-10-24T12:03:08-07:00</updated>
    <id>http://www.morearty.com/blog/2006/10/24/correction-to-the-time-of-my-talk-at-max</id>
    <content type="html"><![CDATA[<p>One page on the MAX website,
<a href="http://www.adobe.com/events/max/sessions/ri205w.html">http://www.adobe.com/events/max/sessions/ri205w.html</a>,
currently lists the wrong day for the second time I&rsquo;m giving my Flex Builder
debugger talk.  As of right now, the page says Tuesday and Wednesday, but it
should say Tuesday and Thursday.  (It will be fixed soon.)  All other web pages
seem to give the correct times.</p>

<p>Here is the correct information:</p>

<p>(1) Tuesday, 1:45 p.m. in Lando, 4303-4304.</p>

<p>(2) Thursday, 12:30 p.m. in Galileo, 1001-1002.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Transparent Flex apps with HTML showing through]]></title>
    <link href="http://www.morearty.com/blog/2006/10/02/transparent-flex-apps-with-html-showing-through/"/>
    <updated>2006-10-02T10:31:20-07:00</updated>
    <id>http://www.morearty.com/blog/2006/10/02/transparent-flex-apps-with-html-showing-through</id>
    <content type="html"><![CDATA[<p>Okay, this is an old trick, Flash has had this for years; but still I think
it&rsquo;s neat, and I&rsquo;m sure some people who are only now coming to the Flash
platform via Flex haven&rsquo;t seen this before.  I was reminded of it when I saw a
<a href="http://tech.groups.yahoo.com/group/flexcoders/message/51611">post on
flexcoders</a> by
Benoit Hediard.</p>

<p>Your Flex apps can let the underlying HTML of the page show through.  The main
case where this is useful is if your page has a background image which would be
difficult to line up with the background of your Flex app.</p>

<p>All you have to do is pass an additional parameter to the <code>&lt;object&gt;</code> and
<code>&lt;embed&gt;</code> tags, to set property <code>wmode</code> to the value <code>transparent</code>:</p>
<div class="highlight"><pre><code class="html language-html" data-lang="html"><span class="nt">&lt;object</span> <span class="err">...</span><span class="nt">&gt;</span>
    ...
    <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;wmode&quot;</span> <span class="na">value=</span><span class="s">&quot;transparent&quot;</span> <span class="nt">/&gt;</span>
    ...
    <span class="nt">&lt;embed</span>
        <span class="err">...</span>
        <span class="na">wmode=</span><span class="s">&quot;transparent&quot;</span>
        <span class="err">...</span> <span class="nt">&gt;</span>
    <span class="nt">&lt;/embed&gt;</span>
<span class="nt">&lt;/object&gt;</span>
</code></pre></div>
<p>Or, in the JavaScript of the HTML template that Flex Builder uses (which comes
from the Flash Player Detection Kit):</p>
<div class="highlight"><pre><code class="javascript language-javascript" data-lang="javascript"><span class="nx">AC_FL_RunContent</span><span class="p">(</span>
    <span class="p">...,</span>
    <span class="s2">&quot;wmode&quot;</span><span class="p">,</span> <span class="s2">&quot;transparent&quot;</span>
<span class="p">);</span>
</code></pre></div>
<p>Then, set the <code>backgroundAlpha</code> of your <code>&lt;mx:Application&gt;</code> to zero, and you&rsquo;re
all set.</p>

<p>Want to see a beautiful example of the result, with my programmer art?  Aww
shucks, it&rsquo;s nothing, you wouldn&rsquo;t be interested.  Oh, okay, <a href="./../../../../assets/2006/10/TransparentBackground/TransparentBackground.html">click
here</a>
to see the example.  Use the slider to try changing the Flex app&rsquo;s
backgroundAlpha.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Talk at MAX - Debugging Flex Applications]]></title>
    <link href="http://www.morearty.com/blog/2006/09/15/talk-at-max-debugging-flex-applications/"/>
    <updated>2006-09-15T13:47:32-07:00</updated>
    <id>http://www.morearty.com/blog/2006/09/15/talk-at-max-debugging-flex-applications</id>
    <content type="html"><![CDATA[<p>At MAX in Las Vegas, I&rsquo;m going to be giving a talk on debugging Flex
applications.  I&rsquo;ll mainly be focusing on Flex Builder&rsquo;s debugger, but I will
also cover a few other tips and tricks.</p>

<p>Also, Tom Reilly from the Flash Player team is sharing my timeslot, and he will
be show a preview of the memory profiler he&rsquo;s been working on.  Very cool
stuff.</p>

<p>Our talk will be given twice: Tuesday, October 24 at 1:45 pm, and Wednesday,
October 25 at 12:30 pm.  The official page for our talk is
<a href="http://www.adobe.com/events/max/sessions/ri205w.html">here</a>.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Simultaneously debug client-side Flex and server-side Java]]></title>
    <link href="http://www.morearty.com/blog/2006/08/30/simultaneously-debug-client-side-flex-and-server-side-java/"/>
    <updated>2006-08-30T15:41:23-07:00</updated>
    <id>http://www.morearty.com/blog/2006/08/30/simultaneously-debug-client-side-flex-and-server-side-java</id>
    <content type="html"><![CDATA[<p>One nice side benefit of the fact that we use Eclipse as the host for Flex
Builder is that it means that within a single IDE, you can simultaneously debug
your client-side Flex code and your server-side Java code.</p>

<p>Eclipse allows you to have several debugging sessions going at the same time.
So the &ldquo;Debug&rdquo; view can have, for example, a Java callstack showing the code in
your server app, and a Flex callstack showing the code in your client-side app.</p>

<p>To do this, you will need to be running the &ldquo;plugin&rdquo; version of Flex Builder &ndash;
the version that runs as a set of plugins on top of a pre-existing Eclipse
installation &ndash; rather than the &ldquo;standalone&rdquo; version.</p>

<p>Last month, James Ward did a <a href="http://www.cayambe.com/wordpress/?p=47">thorough
write-up</a> on how to get this working.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Flex tip: a higher frame rate even makes text entry look better]]></title>
    <link href="http://www.morearty.com/blog/2006/07/17/flex-tip-a-higher-frame-rate-even-makes-text-entry-look-better/"/>
    <updated>2006-07-17T11:17:43-07:00</updated>
    <id>http://www.morearty.com/blog/2006/07/17/flex-tip-a-higher-frame-rate-even-makes-text-entry-look-better</id>
    <content type="html"><![CDATA[<p>I was recently surprised to discover that setting your Flex app&rsquo;s frame rate to
60 frames per second instead of the default of 24 makes typing and selecting
text in edit boxes noticeably smoother.</p>

<p>I&rsquo;ve always noticed that when entering text into a Flash/Flex edit box, it
seems just ever so slightly jittery. I don&rsquo;t usually notice it when typing
text; but if I hold down a key to repeat it &ndash; e.g. Shift+LeftArrow to select
text, or holding down a key to repeat it &ndash; I can see the jitter. (I have my
keyboard repeat rate set to the fastest setting.) By &ldquo;jitter,&rdquo; I mean that the
onscreen display isn&rsquo;t quite keeping up with my typing, so sometimes it will
have to &ldquo;catch up&rdquo; by displaying several characters at once.</p>

<p>This has bugged me for a long time &ndash; after all, since Flash is good at
graphics and animation, it seemed kind of lame that there was perceptible
jitter when doing something as simple as typing and selecting text.</p>

<p>The other day, a rubber band snapped loose somewhere inside my head, and it
occurred to me that perhaps, unlike native applications on most platforms,
perhaps Flash edit controls are only rendered once per frame, rather than being
rendered immediately in response to user actions; and that perhaps the frames
per second was slow enough to be perceptible my eye. This seemed to me to be
unlikely to fix the problem, because after all, the default of 24 frames per
second is the same speed that movie film uses. The whole subject of the eye&rsquo;s
perception of frames per second is actually very complicated &ndash;
<a href="http://www.100fps.com/how_many_frames_can_humans_see.htm">this</a> is an
interesting article on the topic &ndash; but even so, I thought 24 fps would
probably be enough.</p>

<p>I was wrong. For each of the following samples (<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&amp;amp;promoid=BIOW">Flash Player
9.0</a>
required), try selecting text with Shift+LeftArrow or Shift+RightArrow; try
repeating any key such as &ldquo;X&rdquo;; and try typing as quickly as you can. (The
difference on the keyboard-repeat tests will be much more noticeable if you set
your keyboard repeat rate to the fastest setting).</p>

<p>Sample at 24 frames per second:</p>

<p><embed height="70" width="350" src="./../../../../assets/2006/07/TwentyFour.swf"></embed></p>

<p>Samples at 60 frames per second:</p>

<p><embed src="./../../../../assets/2006/07/Sixty.swf" width="350" height="70"></embed></p>

<p>An interactive sample that lets you try out different frame rates:</p>

<p><embed src="./../../../../assets/2006/07/TextTest.swf" width="430" height="120"></embed></p>

<p>So it turns out that making text entry appear smoother is as easy as changing
the frame rate of your applications to about 60 fps.</p>

<p>Are there any disadvantages of increasing the frame rate? The only potential
disadvantage I can think of is that your program might use more CPU. But I ran
some crude tests on several different machines (both Windows and Mac), and
upping the frame rate from 24 fps to 60 fps had a negligible effect on CPU
usage. The higher frame rate caused Flash to use about 1% more CPU during my
typing tests and during some simple animation tests.</p>

<p>So why 60? If 60 frames per second is so great, then why not 100, or more?
Well, I chose 60 somewhat arbitrarily, and all I can say is that I&rsquo;m happy with
60 &ndash; my eye sees no jitter whatsoever at that frame rate. Even though I just
said that the amount of CPU usage from increasing the frame rate is negligible,
there&rsquo;s no point in using extra CPU if it isn&rsquo;t making any difference. As my
mother never used to say, &ldquo;Use all the system resources you need, but no more.&rdquo;</p>

<p>There are also some interesting comments in the documentation for
<code>Stage.frameRate</code>: &ldquo;Note: Flash Player might not be able to follow high frame
rate settings, either because the target platform is not fast enough or the
player is synchronized to the vertical blank timing of the display device
(usually 60 Hz on LCD devices). In some cases, a target platform might also
choose to lower the maximum frame rate if it anticipates high CPU usage.&rdquo;</p>

<p>So, from now on, I plan to specify a frame rate of 60 for <em>all</em> of my Flex applications:</p>
<div class="highlight"><pre><code class="xml language-xml" data-lang="xml"><span class="nt">&lt;mx:application</span> <span class="na">frameRate=</span><span class="s">&quot;60&quot;</span><span class="nt">&gt;</span>
</code></pre></div>
<p>and ActionScript applications:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="o">[</span><span class="n">SWF</span><span class="o">(</span><span class="n">frameRate</span><span class="o">=</span><span class="s2">&quot;60&quot;</span><span class="o">)]</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="n">MyApp</span> <span class="kd">extends</span> <span class="n">Sprite</span>
<span class="o">{</span>
    <span class="o">...</span>
<span class="o">}</span>
</code></pre></div>]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Flex Builder debugger tip: Highlight the breakpoint that was just hit]]></title>
    <link href="http://www.morearty.com/blog/2006/07/06/flex-builder-debugger-tip-highlight-the-breakpoint-that-was-just-hit/"/>
    <updated>2006-07-06T13:23:56-07:00</updated>
    <id>http://www.morearty.com/blog/2006/07/06/flex-builder-debugger-tip-highlight-the-breakpoint-that-was-just-hit</id>
    <content type="html"><![CDATA[<p>A minor tip: I suggest turning on Eclipse&rsquo;s &ldquo;Link with Debug View&rdquo; command in
the Breakpoints view, and leaving it on:</p>

<p><img id="image49" src="./../../../../assets/2006/07/breakpoint-link-with-debug-view.png" alt="breakpoint-link-with-debug-view.png" /></p>

<p>This confusingly named command is actually kind of useful.  The effect of this
command is that every time you hit a breakpoint, the Breakpoints view will
highlight the breakpoint that just got hit.  This is useful after you&rsquo;ve been
debugging for a while, and your Breakpoints view has gotten cluttered with a
bunch of old breakpoints that you haven&rsquo;t gotten around to deleting.</p>

<p>Of course, in a way it&rsquo;s pretty obvious which one you just hit &ndash; after all,
you can see which line you&rsquo;re on &ndash; but still, finding it in the Breakpoints
view can be tedious if there are a lot of breakpoints.</p>

<p>So why is it called &ldquo;Link with Debug View&rdquo; instead of something like &ldquo;Highlight
current breakpoint&rdquo;?  Because Eclipse allows multiple simultaneous debugging
sessions, several of which could be stopped at separate breakpoints.  The
problem is compounded for languages like Java that support multiple threads &ndash;
several threads could be stopped at separate breakpoints.  So, what the &ldquo;Link
with Debug View&rdquo; command actually does is, each time you change the selection
in the Debug view (the view with the callstack), if your new selection
corresponds to a stack frame that is currently at a breakpoint, then the
Breakpoints view will highlight the corresponding line.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[What to do if Flex Builder says, "Installed Flash Player Is Not a Debugger"]]></title>
    <link href="http://www.morearty.com/blog/2006/06/30/what-to-do-if-flex-builder-says-installed-flash-player-is-not-a-debugger/"/>
    <updated>2006-06-30T11:20:51-07:00</updated>
    <id>http://www.morearty.com/blog/2006/06/30/what-to-do-if-flex-builder-says-installed-flash-player-is-not-a-debugger</id>
    <content type="html"><![CDATA[<p>If you have installed Flex Builder, and when try to debug you get an error
message that says &ldquo;Installed Flash Player is not a debugger,&rdquo; or if the Flex
SDK&rsquo;s fdb command-line debugger says, &ldquo;Failed to connect; session timed out,&rdquo;
then see <a href="http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=758bf58b&amp;pss=rss_flex_758bf58b">this
TechNote</a>
to get instructions on how to fix the problem.</p>

<p>A packaging problem with the initial release of Flex Builder and the SDK has
caused a number of people to run into this.  Luckily, fixing it is easy.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Flex 2 has launched! What's new in the debugger since Beta 3]]></title>
    <link href="http://www.morearty.com/blog/2006/06/28/flex-2-has-launched-whats-new-in-the-debugger-since-beta-3/"/>
    <updated>2006-06-28T08:54:03-07:00</updated>
    <id>http://www.morearty.com/blog/2006/06/28/flex-2-has-launched-whats-new-in-the-debugger-since-beta-3</id>
    <content type="html"><![CDATA[<p>An exciting, exciting day!</p>

<p>As for the Flex Builder debugger: Other than bug fixes, there is one tiny new
feature in the debugger since Beta 3.  Sometimes, when looking at source code,
it isn&rsquo;t obvious which lines you can actually set a breakpoint on.  For
example:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="kd">function </span><span class="nf">f</span><span class="o">(</span><span class="n">z</span><span class="o">:</span><span class="kt">int</span><span class="o">):</span><span class="kt">void</span> <span class="c1">// can you set a breakpoint on this line?</span>
<span class="o">{</span>                      <span class="c1">// this one?</span>
  <span class="kd">var</span> <span class="n">i</span><span class="p">:</span><span class="kt">int</span><span class="o">;</span>           <span class="c1">// this one?</span>

  <span class="nf">trace</span><span class="o">(</span>               <span class="c1">// this one?</span>
      <span class="n">z</span>                <span class="c1">// this one?</span>
  <span class="o">);</span>                   <span class="c1">// this one?</span>
<span class="o">}</span>                      <span class="c1">// this one?</span>
</code></pre></div>
<p>The answers depend on how the compiler does its work, and figuring out those
answers requires tedious trial and error.  It&rsquo;s not something people should
have to think about.</p>

<p>So, to make life easier for the user, we made a small change: If you set a
breakpoint but it turns out that there is no actual code on the line you
specified, then we scan down a few lines (ten, actually) to see if we can find
a line that has code on it.  If we do find such a line, then we move your
breakpoint there.</p>

<p>If you set a breakpoint while in the middle of a debugging session, the
breakpoint is adjusted immediately.  If you set a breakpoint before you have
started your debugging session, then the breakpoints are initially left where
you put them, but are then adjusted when you actually begin the debugging
session (click &ldquo;Debug&rdquo;).</p>

<p>Sometimes my favorite features are the ones that transparently &ldquo;just work,&rdquo;
solving a problem so quietly that the user doesn&rsquo;t even realize the feature it
there.  It&rsquo;s a beautiful thing, because it makes the user&rsquo;s life a little
easier, but without giving him something extra to have to think about.  There
is no &ldquo;We&rsquo;ve moved your breakpoints&rdquo; message; that would just distract and
worry the user.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Setting the width and height of a pure-ActionScript application]]></title>
    <link href="http://www.morearty.com/blog/2006/06/27/setting-the-width-and-height-of-a-pure-actionscript-application/"/>
    <updated>2006-06-27T14:38:50-07:00</updated>
    <id>http://www.morearty.com/blog/2006/06/27/setting-the-width-and-height-of-a-pure-actionscript-application</id>
    <content type="html"><![CDATA[<p>For a Flex project with MXML files, it is obvious how to set the width and
height of the project:</p>
<div class="highlight"><pre><code class="xml language-xml" data-lang="xml"><span class="nt">&lt;mx:Application</span> <span class="na">width=</span><span class="s">&quot;300&quot;</span> <span class="na">height=</span><span class="s">&quot;200&quot;</span><span class="nt">&gt;</span>
</code></pre></div>
<p>But for pure-ActionScript projects, it isn&rsquo;t so obvious.  The way to do it is
to use the <code>SWF</code> metadata attribute above the declaration of the class:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="kd">package</span>
<span class="o">{</span>
  <span class="o">[</span><span class="n">SWF</span><span class="o">(</span><span class="n">width</span><span class="o">=</span><span class="s2">&quot;300&quot;</span><span class="o">,</span> <span class="n">height</span><span class="o">=</span><span class="s2">&quot;200&quot;</span><span class="o">)]</span>
  <span class="kd">public</span> <span class="kd">class</span> <span class="n">MyApp</span> <span class="kd">extends</span> <span class="n">Sprite</span>
  <span class="o">{</span>
    <span class="o">...</span>
  <span class="o">}</span>
<span class="o">}</span>
</code></pre></div>
<p>The values specified there are pixel sizes; in this context, you are not
allowed to use percentage values such as 100%.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Writing your own plugins for the Flex Builder debugger, part 2: a fully functional sample]]></title>
    <link href="http://www.morearty.com/blog/2006/06/07/writing-your-own-plugins-for-the-flex-builder-debugger-part-2-a-fully-functional-sample/"/>
    <updated>2006-06-07T13:35:20-07:00</updated>
    <id>http://www.morearty.com/blog/2006/06/07/writing-your-own-plugins-for-the-flex-builder-debugger-part-2-a-fully-functional-sample</id>
    <content type="html"><![CDATA[<p>Let&rsquo;s write a plugin for the Flex Builder debugger.  This will be a simple
panel called Expression Tracker, which is like the Expressions view except that
it does not refresh its displayed values each time you step.  Don&rsquo;t expect
anything useful or beautiful here; this is just a barely-functional sample with
a pretty rotten UI.  But it&rsquo;s a start.</p>

<p>I should warn you that creating Eclipse plugins takes a large investment of
effort to understand how they fit together.</p>

<h3>Eclipse cruft</h3>

<ul>
<li><p>You&rsquo;ll need to be using the plugin-based version of Flex Builder rather than
the standalone version.  This means that first, you have to install Eclipse
version 3.1.2 from <a href="http://www.eclipse.org">http://www.eclipse.org</a>.  Then, you
have to install the plugin version of Flex Builder:</p>

<p><img id="image38" src="./../../../../assets/2006/05/installer.png" alt="installer.png" /></p>

<p>The standalone version of Flex Builder is only for writing and debugging
Flex applications.  But the plugin version is a set of plugins that you
install on top of Eclipse, to enable the creation of Flex projects in
<em>addition</em> to other types of projects.  Flex Builder plugins are written in
Java.</p></li>
<li><p>File &gt; New &gt; Project; Plug-in Development &gt; Plug-in Project.</p></li>
<li><p>Project name: &ldquo;ExpressionTracker&rdquo;.  Click Next, then Next.</p></li>
<li><p>Use the &ldquo;Plug-in with a view&rdquo; template, so Eclipse will fill in some boilerplate code for us:</p>

<p><img id="image29" src="./../../../../assets/2006/05/plugin-template.png" alt="plugin-template.png" /></p></li>
<li><p>Click Next, and change the classname and a few other settings as follows.
The &ldquo;View Class Name&rdquo; is the name of the Java class; the &ldquo;View Name&rdquo; is the
name displayed to the user in the tab for that view; and the &ldquo;View Category
ID&rdquo; and &ldquo;View Category Name&rdquo; control where it shows up under &ldquo;Window &gt; Show
View &gt; Other&rdquo;:</p>

<p><img id="image39" src="./../../../../assets/2006/06/plugin-settings.png" alt="plugin-settings.png" /></p>

<p>The above settings will cause your view to show up in the &ldquo;Flex&rdquo; category
of views.  If you would rather have your plugin show up in the &ldquo;Debug&rdquo;
category, then use a View Category ID of <code>org.eclipse.debug.ui</code>, and a view
category name of &ldquo;Debug&rdquo;.  Or, make your own new category if you want, such
as &ldquo;Acme Awesome Flex Extensions.&rdquo;</p></li>
<li><p>Click Finish.</p></li>
</ul>

<p>Let&rsquo;s see what we have so far.  Select the ExpressionConsole project in the
Package Explorer view, then do Run &gt; Run As &gt; Eclipse Application.  Then, in
the newly launched Eclipse, Window &gt; Show View &gt; Other; Debug &gt; Expression
Tracker.</p>

<p><img id="image32" src="./../../../../assets/2006/05/view1.png" alt="view1.png" /></p>

<p>Hey, it worked!  Okay, now we get to the interesting part.</p>

<h3>The interesting part</h3>

<ul>
<li><p>Start by opening <code>ExpressionTrackerView.java</code> and exploring for a bit.  The
various Eclipse templates are very useful for showing you how to hook
everything together.  In here, you will see some simple examples of
context-menu commands, double-click handlers, and so on.</p></li>
<li><p>Insert these two functions into <code>ExpressionTrackerPlugin.java</code>.  You should
put these in every Eclipse plugin you make, and whenever you have caught an
exception that indicate an error condition, you should call
<code>«YourPluginClass».log()</code>, to send it to the &ldquo;Error Log&rdquo; view:</p>
<div class="highlight"><pre><code class="java language-java" data-lang="java"><span class="cm">/**</span>
<span class="cm"> * Logs the given status to this plug-in&#39;s error log.</span>
<span class="cm"> * </span>
<span class="cm"> * @param message</span>
<span class="cm"> *            general message, e.g. &quot;Error during initialization&quot;</span>
<span class="cm"> * @param t</span>
<span class="cm"> *            exception associated with this error, or null</span>
<span class="cm"> */</span>
<span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">log</span><span class="o">(</span><span class="n">String</span> <span class="n">message</span><span class="o">,</span> <span class="n">Throwable</span> <span class="n">t</span><span class="o">)</span> <span class="o">{</span>
  <span class="n">getDefault</span><span class="o">().</span><span class="na">getLog</span><span class="o">().</span><span class="na">log</span><span class="o">(</span><span class="n">createStatusError</span><span class="o">(</span><span class="n">message</span><span class="o">,</span> <span class="n">t</span><span class="o">));</span>
<span class="o">}</span>

<span class="cm">/**</span>
<span class="cm"> * Create and return an IStatus object with ERROR severity and the given</span>
<span class="cm"> * message and exception.</span>
<span class="cm"> */</span>
<span class="kd">public</span> <span class="kd">static</span> <span class="n">IStatus</span> <span class="nf">createStatusError</span><span class="o">(</span><span class="n">String</span> <span class="n">message</span><span class="o">,</span> <span class="n">Throwable</span> <span class="n">t</span><span class="o">)</span> <span class="o">{</span>
  <span class="k">if</span> <span class="o">(</span><span class="n">message</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
    <span class="n">message</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="na">getLocalizedMessage</span><span class="o">();</span>
    <span class="k">if</span> <span class="o">(</span><span class="n">message</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span>
      <span class="n">message</span> <span class="o">=</span> <span class="s">&quot;&quot;</span><span class="o">;</span>
  <span class="o">}</span>
  <span class="k">return</span> <span class="k">new</span> <span class="nf">Status</span><span class="o">(</span><span class="n">IStatus</span><span class="o">.</span><span class="na">ERROR</span><span class="o">,</span> <span class="n">getDefault</span><span class="o">().</span><span class="na">getBundle</span><span class="o">()</span>
    <span class="o">.</span><span class="na">getSymbolicName</span><span class="o">(),</span> <span class="n">IStatus</span><span class="o">.</span><span class="na">ERROR</span><span class="o">,</span> <span class="n">message</span><span class="o">,</span> <span class="n">t</span><span class="o">);</span>
<span class="o">}</span>
</code></pre></div></li>
<li><p>Replace your <code>ExpressionTrackerView.java</code> with <a href="./../../../../assets/2006/06/ExpressionTrackerView.java">this completed
version</a>.</p></li>
</ul>

<p>Let&rsquo;s go through that new version and look at the interesting debugger-related
parts.  Given an expression, how do you get its value?  Answer: You get a
reference to Eclipse&rsquo;s global &ldquo;expression manager;&rdquo; tell it to create an
expression; tell that expression to evaluate itself in a specified context
(stack frame); and then wait until Eclipse sends you an event telling you the
evaluation has completed.  The relevant source:</p>

<p><code>ExpressionTrackerView</code> constructor: Start listening for all debug events.</p>
<div class="highlight"><pre><code class="java language-java" data-lang="java"><span class="kd">public</span> <span class="nf">ExpressionTrackerView</span><span class="o">()</span> <span class="o">{</span>
  <span class="c1">// We register to be notified of all debug-related events, so that</span>
  <span class="c1">// we will be notified whenever an expression has been evaluated.</span>
  <span class="n">DebugPlugin</span><span class="o">.</span><span class="na">getDefault</span><span class="o">().</span><span class="na">addDebugEventListener</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>
<span class="o">}</span>
</code></pre></div>
<p><code>ExpressionAndValue</code> constructor: the user has said to add a new expression to
the view.  Create it, and tell it to evaluate itself.</p>
<div class="highlight"><pre><code class="java language-java" data-lang="java"><span class="c1">// Get the expression manager, and create a new watch expression</span>
<span class="n">IExpressionManager</span> <span class="n">expressionManager</span> <span class="o">=</span> <span class="n">DebugPlugin</span><span class="o">.</span><span class="na">getDefault</span><span class="o">().</span><span class="na">getExpressionManager</span><span class="o">();</span>
<span class="n">watchExpr</span> <span class="o">=</span> <span class="n">expressionManager</span><span class="o">.</span><span class="na">newWatchExpression</span><span class="o">(</span><span class="n">expr</span><span class="o">);</span>

<span class="c1">// Figure out the &quot;context&quot; of this watch expression -- that is, which</span>
<span class="c1">// stack frame is currently selected in Eclipse&#39;s &quot;Debug&quot; view?</span>
<span class="n">IDebugElement</span> <span class="n">debugElement</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="n">IAdaptable</span> <span class="n">debugContext</span> <span class="o">=</span> <span class="n">DebugUITools</span><span class="o">.</span><span class="na">getDebugContext</span><span class="o">();</span>
<span class="k">if</span> <span class="o">(</span><span class="n">debugContext</span> <span class="o">!=</span> <span class="kc">null</span><span class="o">)</span>
  <span class="n">debugElement</span> <span class="o">=</span> <span class="o">(</span><span class="n">IDebugElement</span><span class="o">)</span> <span class="n">debugContext</span><span class="o">.</span><span class="na">getAdapter</span><span class="o">(</span><span class="n">IDebugElement</span><span class="o">.</span><span class="na">class</span><span class="o">);</span>

<span class="k">if</span> <span class="o">(</span><span class="n">debugElement</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
  <span class="n">value</span> <span class="o">=</span> <span class="s">&quot;&lt;no debug context&gt;&quot;</span><span class="o">;</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
  <span class="c1">// Have the watch expression begin evaluating itself.  When it is</span>
  <span class="c1">// done, it will dispatch a DebugEvent, which we will see in our</span>
  <span class="c1">// handleDebugEvents() function.</span>
  <span class="n">value</span> <span class="o">=</span> <span class="s">&quot;...&quot;</span><span class="o">;</span>
  <span class="n">watchExpr</span><span class="o">.</span><span class="na">setExpressionContext</span><span class="o">(</span><span class="n">debugElement</span><span class="o">);</span>
  <span class="n">watchExpr</span><span class="o">.</span><span class="na">evaluate</span><span class="o">();</span>
<span class="o">}</span>
</code></pre></div>
<p><code>ExpressionTrackerView.handleDebugEvents()</code>: Called by Eclipse whenever any
debugger-related event takes place &ndash; a process starts or terminates, a
breakpoint is hit, etc.  Our code will look for debug events that indicate that
one of our expressions has been evaluated, and when it has, call
<code>ExpressionAndValue.doneEvaluating()</code>:</p>
<div class="highlight"><pre><code class="java language-java" data-lang="java"><span class="kd">public</span> <span class="kt">void</span> <span class="nf">handleDebugEvents</span><span class="o">(</span><span class="n">DebugEvent</span><span class="o">[]</span> <span class="n">events</span><span class="o">)</span> <span class="o">{</span>
  <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="o">;</span> <span class="n">i</span><span class="o">&lt;</span><span class="n">events</span><span class="o">.</span><span class="na">length</span><span class="o">;</span> <span class="o">++</span><span class="n">i</span><span class="o">)</span> <span class="o">{</span>
    <span class="n">DebugEvent</span> <span class="n">event</span> <span class="o">=</span> <span class="n">events</span><span class="o">[</span><span class="n">i</span><span class="o">];</span>
    <span class="k">if</span> <span class="o">(</span><span class="n">event</span><span class="o">.</span><span class="na">getKind</span><span class="o">()</span> <span class="o">==</span> <span class="n">DebugEvent</span><span class="o">.</span><span class="na">CHANGE</span><span class="o">)</span> <span class="o">{</span>
      <span class="n">Object</span> <span class="n">source</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="na">getSource</span><span class="o">();</span>
      <span class="k">if</span> <span class="o">(</span><span class="n">source</span> <span class="k">instanceof</span> <span class="n">IWatchExpression</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">j</span><span class="o">=</span><span class="mi">0</span><span class="o">;</span> <span class="n">j</span><span class="o">&lt;</span><span class="n">items</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="o">++</span><span class="n">j</span><span class="o">)</span> <span class="o">{</span>
          <span class="n">ExpressionAndValue</span> <span class="n">item</span> <span class="o">=</span> <span class="o">(</span><span class="n">ExpressionAndValue</span><span class="o">)</span> <span class="n">items</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">j</span><span class="o">);</span>
          <span class="k">if</span> <span class="o">(</span><span class="n">item</span><span class="o">.</span><span class="na">watchExpr</span> <span class="o">==</span> <span class="n">source</span><span class="o">)</span> <span class="o">{</span>
            <span class="n">item</span><span class="o">.</span><span class="na">doneEvaluating</span><span class="o">();</span>
            <span class="k">break</span><span class="o">;</span>
          <span class="o">}</span>
        <span class="o">}</span>
      <span class="o">}</span>
    <span class="o">}</span>
  <span class="o">}</span>
<span class="o">}</span>
</code></pre></div>
<p><code>ExpressionAndValue.doneEvaluating()</code>: Check if the expression evaluation
encountered errors, such as syntax errors.  If so, display the error;
otherwise, display the vlaue.</p>
<div class="highlight"><pre><code class="java language-java" data-lang="java"><span class="k">if</span> <span class="o">(</span><span class="n">watchExpr</span><span class="o">.</span><span class="na">hasErrors</span><span class="o">())</span> <span class="o">{</span>
  <span class="n">String</span><span class="o">[]</span> <span class="n">errorMessages</span> <span class="o">=</span> <span class="n">watchExpr</span><span class="o">.</span><span class="na">getErrorMessages</span><span class="o">();</span>
  <span class="k">if</span> <span class="o">(</span><span class="n">errorMessages</span><span class="o">.</span><span class="na">length</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="o">)</span> <span class="o">{</span>
    <span class="c1">// We should really display all the error messages,</span>
    <span class="c1">// not just the first...</span>
    <span class="k">this</span><span class="o">.</span><span class="na">value</span> <span class="o">=</span> <span class="n">errorMessages</span><span class="o">[</span><span class="mi">0</span><span class="o">];</span>
  <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="na">value</span> <span class="o">=</span> <span class="s">&quot;Error&quot;</span><span class="o">;</span>
  <span class="o">}</span>
<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
  <span class="n">IValue</span> <span class="n">exprValue</span> <span class="o">=</span> <span class="n">watchExpr</span><span class="o">.</span><span class="na">getValue</span><span class="o">();</span>
  <span class="k">if</span> <span class="o">(</span><span class="n">exprValue</span> <span class="o">!=</span> <span class="kc">null</span><span class="o">)</span>
    <span class="k">this</span><span class="o">.</span><span class="na">value</span> <span class="o">=</span> <span class="n">exprValue</span><span class="o">.</span><span class="na">getValueString</span><span class="o">();</span>
  <span class="k">else</span>
    <span class="k">this</span><span class="o">.</span><span class="na">value</span> <span class="o">=</span> <span class="s">&quot;&quot;</span><span class="o">;</span>
<span class="o">}</span>
</code></pre></div>
<p>That is pretty much all the debugger-related functionality in the code.  Give
it a try now.  Run a child instance of Eclipse again.  Create a Flex Builder
project.  Open the Expression Tracker view.  Right-click, and add an expression
or two.</p>

<p><img id="image40" src="./../../../../assets/2006/06/working.png" alt="working.png" /></p>

<p>A masterpiece.</p>

<h3>Publishing your masterpiece</h3>

<p>The main thing you need to know is: File &gt; Export &gt; Deployable plug-ins and
fragments.  This command will package up your plugin in a form that is easy to
publish.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Writing your own plugins for the Flex Builder debugger, part 1: where to start]]></title>
    <link href="http://www.morearty.com/blog/2006/05/31/writing-your-own-plugins-for-the-flex-builder-debugger-part-1-where-to-start/"/>
    <updated>2006-05-31T09:07:52-07:00</updated>
    <id>http://www.morearty.com/blog/2006/05/31/writing-your-own-plugins-for-the-flex-builder-debugger-part-1-where-to-start</id>
    <content type="html"><![CDATA[<p>Is there a feature missing from the Flex Builder debugger that you really wish
we had put in?</p>

<p>No?  Right, move along then.</p>

<p>Oh, what&rsquo;s that?  Yes, there is such a feature?  Well then, now is your chance
for fame and glory.  (Notice I didn&rsquo;t say fortune.  That part probably takes
more work than just writing a plugin.)</p>

<p>There is bad news and good news.  The bad news is, in this release we will not
be publishing the Flex-specific debugger APIs that live inside Flex Builder.
We just haven&rsquo;t had time to clean them up and test them to the degree that we
would be comfortable releasing them as documented, supported APIs.</p>

<p><em>But,</em> the good news is, our lack of Flex-specific APIs is not as big a problem
as it might sound like at first, because Eclipse itself has a very clean,
well-documented set of APIs for accessing generic debugger-related
functionality (variables, breakpoints, callstacks, etc.).  And it turns out
that the vast majority of stuff that you can think of putting into a Flex
Builder debugger plugin is actually generic debugger stuff, not Flex-specific.</p>

<p>For example, using the Eclipse APIs, here are a few things you can easily do
within your own Flex Builder plugin:</p>

<ul>
<li>given a string, evaluate it as an expression</li>
<li>change the value of a variable</li>
<li>set a breakpoint</li>
<li>determine the current callstack</li>
<li>programmatically invoke step-into, step-over, resume, terminate, etc.</li>
</ul>

<p>Okay, so where to start?  In future posts I will give some actual code samples,
but for now, here are a few key starting points inside Eclipse:</p>

<ul>
<li><p>Much of the key stuff is in the Java package <code>org.eclipse.debug.core.model</code>
&ndash; this includes <code>IVariable</code>, <code>IValue</code>, <code>IThread</code>, <code>IStackFrame</code>,
<code>IDebugTarget</code> (a program being debugged), <code>IProcess</code> (a program that was
launched with either Debug or Run), <code>IBreakpoint</code>, <code>ILineBreakpoint</code>,
<code>IExpression</code>, <code>IWatchExpression</code>.</p></li>
<li><p>Also, a common starting point for getting anything done is a call to
<code>org.eclipse.debug.core.DebugPlugin.getDefault()</code>.  From there, you can get
to the <code>IBreakpointManager</code>, <code>ILaunchManager</code> (again, a &ldquo;launch&rdquo; is anything
that you launched with either Debug or Run), and <code>IExpressionManager</code>; and
add a debug event listener so your code is notified when something
interesting happens.</p></li>
<li><p>Finally, class <code>org.eclipse.debug.ui.DebugUITools</code> has some useful helper
functions.  In particular, <code>DebugUITools.getDebugContext()</code> is more important
than its bland name implies.  The &ldquo;debug context&rdquo; is whatever is selected in
the Debug view, such as a particular stack frame.  This ends up affecting
lots of things, like which variables are shown in the Variables view, and how
expressions are evaluated: Expressions are evaluated in the context of the
current stack frame.</p></li>
</ul>

<p>The online documentation for all the Eclipse debugger classes is
<a href="http://help.eclipse.org/help30/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/overview-summary.html">here</a>
(scroll down to the <code>org.eclipse.debug.*</code> packages).</p>

<p>Finally, I want to warn you that learning how to write Eclipse plugins is a
very time-consuming undertaking.  Eclipse is <em>extremely</em> modular &ndash; there are
<a href="http://en.wikipedia.org/wiki/Design_Patterns">design patterns</a> everywhere you
turn.  And that&rsquo;s a good thing, because it gives you tremendous power to plug
into it at any level (if this weren&rsquo;t the case, we wouldn&rsquo;t have been able to
create something like Flex Builder on top of it).  </p>

<p>But the downside of this modularity is that it&rsquo;s really hard to just plunge in
and start creating useful code, because it can be very hard to figure out how
to get from point A to point B.  (An example: Early on, I tried to figure out
the code path from &ldquo;user double-clicks in the margin of a document&rdquo; to &ldquo;blue
circle shows up indicating a breakpoint has been created.&rdquo;  Whoo boy.)  It took
me about a month of full-time development before the lightbulb in my head
finally lit up and I &ldquo;got&rdquo; how everything fits together; I then began to find
it much quicker to write code.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Flex Builder: Ctrl-click to access a launch config's properties]]></title>
    <link href="http://www.morearty.com/blog/2006/05/23/flex-builder-ctrl-click-to-access-a-launch-configs-properties/"/>
    <updated>2006-05-23T14:17:04-07:00</updated>
    <id>http://www.morearty.com/blog/2006/05/23/flex-builder-ctrl-click-to-access-a-launch-configs-properties</id>
    <content type="html"><![CDATA[<p>This is probably documented somewhere &ndash; it is a standard feature of Eclipse &ndash;
but I thought I would mention that if you want to view and/or edit the
properties of a launch configuration (you know the Run &gt; Debug&hellip; or Run &gt;
Run&hellip; dialog), a shortcut to do that is to click the Debug or Run dropdown
icon on the toolbar, and then control-click on the configuration you want to
edit.  A regular click, of course, will launch that configuration; but a
control-click will bring up the dialog to edit it.</p>

<p><img id="image23" src="./../../../../assets/2006/05/ctrl-click.png" alt="ctrl-click.png" /></p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Undocumented Flex Builder: changing the syntax coloring]]></title>
    <link href="http://www.morearty.com/blog/2006/05/22/undocumented-flex-builder-changing-the-syntax-coloring/"/>
    <updated>2006-05-22T14:42:21-07:00</updated>
    <id>http://www.morearty.com/blog/2006/05/22/undocumented-flex-builder-changing-the-syntax-coloring</id>
    <content type="html"><![CDATA[<p>Naturally, Flex Builder does syntax coloring when displaying your .mxml, .as,
and .css files.  As of this first release, we don&rsquo;t have a way for you to
change the colors that are used.  But if you don&rsquo;t like them, you can change
them &ndash; just please be aware that this technique is entirely undocumented and
unsupported.  (Doesn&rsquo;t that just give you a thrill?  Funny how learning about
anything which is undocumented &ndash; even something as trivial as this &ndash; makes
you feel like you&rsquo;re stickin&#39; it to the man.)</p>

<p>Anyway, inside your Flex Builder directory, look for a folder called</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">plugins\com.adobe.flexbuilder.editors.common_2.0.XXX
</code></pre></div>
<p>where <code>XXX</code> is a version number &ndash; for example, <code>340</code> for Beta 3.</p>

<p>Inside that directory is a file called <code>common.jar</code>.  Open this file with
WinZip or any other zip software.  (In case you didn&rsquo;t know, Java <code>.jar</code> files
are actually the sample file format as <code>.zip</code> files.  Probably the easiest way
to open the file is to copy <code>common.jar</code> to <code>common.zip</code>, and then just
double-click it.)</p>

<p>In there, you will see <code>Colors.xml</code>.  That&rsquo;s your baby.  Oh, the excitement,
we&rsquo;ve found the top secret undocumented stuff!  The format of the file is
pretty obvious: an XML file with three sections &ndash; one for ActionScript, one
for MXML, and one for CSS.  Just modify the following attributes of any tag:</p>

<ul>
<li><code>text=&quot;rrggbb&quot;</code> &ndash; foreground color (standard red/green/blue format)</li>
<li><code>bold=&quot;true&quot;</code> or <code>&quot;false&quot;</code></li>
<li><code>italic=&quot;true&quot;</code> or <code>&quot;false&quot;</code></li>
</ul>

<p>Then when you&rsquo;re done, save your modified <code>Colors.xml</code> back into <code>common.jar</code>
(after first making a backup of <code>common.jar</code>, of course.)</p>

<p>In case it wasn&rsquo;t obvious: <em><strong>This whole thing is undocumented and
unsupported.</strong>  You do this AT YOUR OWN RISK.</em>  And, of course, it may change
in future versions of Flex Builder.  In fact, it probably <em>will</em> change, when
we eventually add support for customizing your colors.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Customizing Flex Builder's HTML templates]]></title>
    <link href="http://www.morearty.com/blog/2006/05/19/customizing-flex-builders-html-templates/"/>
    <updated>2006-05-19T11:26:21-07:00</updated>
    <id>http://www.morearty.com/blog/2006/05/19/customizing-flex-builders-html-templates</id>
    <content type="html"><![CDATA[<p>When you create a new project, Flex Builder creates a directory in the project
called <code>html-template</code>, which contains a generic HTML wrapper for your Flash
application.  The files in that directory are based on the project properties
under the &ldquo;Flex Compiler&rdquo; tab (for Flex projects) or the &ldquo;ActionScript
Compiler&rdquo; tab (for ActionScript projects).</p>

<p>If you want to customize the template for a single project, that&rsquo;s easy &ndash; just
modify the files that are in <code>«myproject»\html-template</code>.</p>

<p>If you want to modify the templates that are generated for <em>all</em> new projects,
that can be done too, although it takes a little more effort.  The HTML
wrappers are in</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">«myworkspace»\.metadata\.plugins\com.adobe.flexbuilder.project\html-templates
</code></pre></div>
<p>where <code>«myworkspace»</code> is, um, your workspace &ndash; that is, the directory you see
if you do File &gt; Switch Workspace.  (After doing File &gt; Switch Workspace and
copying the dir, you can just click Cancel, to sta in the current workspace.)</p>

<p>In that directory, you will see six subdirectories.  These correspond to the
different options in the above-mentioned project properties page:</p>

<ul>
<li>  client-side-detection</li>
<li>  client-side-detection-with-history</li>
<li>  express-installation</li>
<li>  express-installation-with-history</li>
<li>  no-player-detection</li>
<li>  no-player-detection-with-history</li>
</ul>

<p>So, go to those directories; customize all you want; and then re-launch Flex
Builder.  From then on, any <em>new</em> projects you create will use the modified
templates.</p>

<p>I should warn you that if you make any customizations in this area, there is a
chance they may get clobbered when the final release of Flex Builder comes out.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Beta 3]]></title>
    <link href="http://www.morearty.com/blog/2006/05/09/beta-3/"/>
    <updated>2006-05-09T15:31:35-07:00</updated>
    <id>http://www.morearty.com/blog/2006/05/09/beta-3</id>
    <content type="html"><![CDATA[<p>Beta 3 of Flex 2.0 has <a href="http://labs.adobe.com/flexproductline/">been released</a>!</p>

<p>For those of you who have been too busy to try Flex: if nothing else, at least
install the beta of <a href="http://labs.adobe.com/technologies/flashplayer9/">Flash Player
9</a>, so that you can see all
the cool samples that are on Adobe Labs and elsewhere, such a <a href="http://kuwamoto.org/">Sho&rsquo;s
blog</a> and <a href="http://www.quietlyscheming.com/blog/">Ely&rsquo;s
blog</a>.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Quick fix]]></title>
    <link href="http://www.morearty.com/blog/2006/05/09/quick-fix/"/>
    <updated>2006-05-09T10:41:36-07:00</updated>
    <id>http://www.morearty.com/blog/2006/05/09/quick-fix</id>
    <content type="html"><![CDATA[<p>David Zuckerman, also on the Flex Builder team, has written a <a href="http://davidzuckerman.com/adobe/2006/05/08/alpha-plugin-featuring-quick-fix-support-and-error-highlighting-in-flex-builder-2-beta-3-released/">totally awesome
extension
plugin</a>
for Flex Builder.  It provides &ldquo;Quick Fix&rdquo; &ndash; with a quick keystroke or two,
you can tell Flex Builder to automatically fix certain common errors and
warnings.  For example, say you wrote this:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="kd">function </span><span class="nf">f</span><span class="o">()</span>
<span class="o">{</span>
    <span class="k">return</span> <span class="s2">&quot;hello&quot;</span><span class="o">;</span>
<span class="o">}</span>
</code></pre></div>
<p>The compiler will warn you that function <code>f()</code> has no type.  But, Ctrl-1, Quick
Fix, and voilà &ndash; Flex Builder guesses that the return value of <code>f()</code> should be
of type String:</p>
<div class="highlight"><pre><code class="actionscript3 language-actionscript3" data-lang="actionscript3"><span class="kd">function </span><span class="nf">f</span><span class="o">():</span><span class="kt">String</span>
<span class="o">{</span>
    <span class="k">return</span> <span class="s2">&quot;hello&quot;</span><span class="o">;</span>
<span class="o">}</span>
</code></pre></div>
<p>Here&rsquo;s a screenshot of QuickFix adding a type to a variable:</p>

<p><img src="http://davidzuckerman.com/adobe/wp-content/assets/2006/05/quickFix1.jpg"></p>

<p>There is lots more.  It is <em>highly</em> recommended.</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[How Flex Builder launches the Flash Player]]></title>
    <link href="http://www.morearty.com/blog/2006/05/08/how-flex-builder-launches-the-flash-player/"/>
    <updated>2006-05-08T23:22:09-07:00</updated>
    <id>http://www.morearty.com/blog/2006/05/08/how-flex-builder-launches-the-flash-player</id>
    <content type="html"><![CDATA[<p>In <a href="http://labs.adobe.com/technologies/flexbuilder2/">Flex Builder 2.0</a>, when
you click Debug or Run, Flex Builder launches the Flash Player. But <em>which</em>
Flash Player?</p>

<p>By default, it launches your system&rsquo;s default web browser. However, you can
change that if you need to.</p>

<p>If you go to Window &gt; Preferences, General, Web Browser, you will see a
preference for which browser to use. This preference controls which browser to
use for <em>everything</em> in Eclipse, not just which browser to use for Flex
Builder&rsquo;s debugging. For example, it controls which browser will be used if you
double click on a .html file in the Navigator view.</p>

<p>But there is another option. I often like to use the standalone Flash player
(SAFlashPlayer.exe), because it launches a bit faster than the browser. There
are times when you really need your Flash app to be running &ldquo;in context&rdquo; inside
an HTML page, such as when the Flash app and the JavaScript on the page are
interacting with each other; but if that is not the case, then you might like
debugging with the standalone Flash player.</p>

<p>Doing that is easy, although not obvious: Go to the Run &gt; Debug&hellip; dialog, and
change the launch URL so that it ends with <code>.swf</code> instead of <code>.html</code>. For
example, if the URL is <code>C:\MyProject\MyProject-debug.html</code>, change it to
<code>C:\MyProject\MyProject-debug.swf</code>.</p>

<p>Note that this only works for local URLs. HTTP and HTTPS URLs always cause a
web browser to run, never the standalone Flash player.</p>

<p>Click for an example:</p>

<p><a class="imagelink" title="Debug dialog" href="./../../../../assets/2006/05/debug-dialog.gif"><img id="image7" height=96 alt="Debug dialog" src="./../../../../assets/2006/05/debug-dialog.thumbnail.gif" /></a></p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Killer Flex Builder 2.0 keyboard shortcuts]]></title>
    <link href="http://www.morearty.com/blog/2006/05/05/killer-flex-builder-20-keyboard-shortcuts/"/>
    <updated>2006-05-05T15:51:28-07:00</updated>
    <id>http://www.morearty.com/blog/2006/05/05/killer-flex-builder-20-keyboard-shortcuts</id>
    <content type="html"><![CDATA[<p>Flex Builder 2.0 has some really great ways to quickly navigate through your
source code &ndash; e.g. &ldquo;go to definition&rdquo; and stuff like that. Most of these are
based on similar features in Eclipse&rsquo;s Java editing environment (the JDT).</p>

<p><strong>Ctrl-O:</strong> Lightweight popup with list of functions in current file. Great for
quick navigation within a file.</p>

<p><strong>Ctrl-Shift-T:</strong> Open type. A quick way to go to the source for any class.</p>

<p><strong>Ctrl-Click or F3:</strong> Go to definition. Ctrl-click on just about anything &ndash;
function name, variable name, etc. &ndash; to go to its definition. F3 does the same
thing.</p>

<p><strong>Alt-Left, Alt-Right;</strong> or yellow arrows on toolbar: Back, Forward navigation,
like in a web browser.</p>

<p><strong>Ctrl-Shift-O:</strong> Organize imports &ndash; makes them alphabetical and tidy.</p>

<p><strong>Ctrl-Space:</strong> Code hinting (of course).</p>

<p><strong>Ctrl-Shift-Space:</strong> Restores tooltip showing the args of the function you are
trying to call, e.g. if you have already written &ldquo;foo(&rdquo; but then moved
somewhere else so the codehint had gone away</p>
]]></content>
  </entry>
  
    <entry>
    <title type="html"><![CDATA[Hello world]]></title>
    <link href="http://www.morearty.com/blog/2006/05/05/hello-world/"/>
    <updated>2006-05-05T10:06:20-07:00</updated>
    <id>http://www.morearty.com/blog/2006/05/05/hello-world</id>
    <content type="html"><![CDATA[<p>I&rsquo;m a <a href="http://www.linkedin.com/in/mmorearty">freelance software developer</a>.  I
spent eight years at Adobe, working on Flash Builder and Dreamweaver.  Before
that, I spent ten years at Microsoft, where I worked on Visual Studio&rsquo;s
debugger for a number of years, then on interactive TV, and then on
sidewalk.com.</p>
]]></content>
  </entry>
  
</feed>
