<?xml version="1.0" encoding="UTF-8"?>
<feed
  xmlns="http://www.w3.org/2005/Atom"
  xmlns:thr="http://purl.org/syndication/thread/1.0"
  xml:lang="en"
   >
  <title type="text">Code Kills</title>
  <subtitle type="text"></subtitle>

  <updated>2012-01-22T21:05:58Z</updated>
  <generator uri="http://blogofile.com/">Blogofile</generator>

  <link rel="alternate" type="text/html" href="http://blog.codekills.net" />
  <id>http://blog.codekills.net/feed/atom/</id>
  <link rel="self" type="application/atom+xml" href="http://blog.codekills.net/feed/atom/" />
  <entry>
    <author>
      <name>David Wolever</name>
      <uri>http://blog.codekills.net</uri>
    </author>
    <title type="html">AsyncResult — making async in ActionScript suck less</title>
    <link rel="alternate" type="text/html" href="http://blog.codekills.net/2010/10/09/asyncresult---making-async-in-actionscript-suck-less" />
    <id>http://blog.codekills.net/2010/10/09/asyncresult---making-async-in-actionscript-suck-less</id>
    <updated>2010-10-10T01:47:00Z</updated>
    <published>2010-10-10T01:47:00Z</published>
    <category scheme="http://blog.codekills.net" term="ActionScript" />
    <summary type="html">AsyncResult — making async in ActionScript suck less</summary>
    <content type="html" xml:base="http://blog.codekills.net/2010/10/09/asyncresult---making-async-in-actionscript-suck-less">

&lt;p&gt;Let&#39;s face it: the tools Adobe provides for dealing with asynchronous
operations in ActionScript are basically crap. We&#39;ve got &lt;a href=&#34;http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/IResponder.html&#34;&gt;AsyncToken&lt;/a&gt;, which
seems pretty good... Until you try and use it yourself, and realize that
there&#39;s no way to inject your own result. And then we&#39;ve got the &lt;a href=&#34;http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/IResponder.html&#34;&gt;IResponder&lt;/a&gt;
interface, which also seems pretty good... Except that sometimes your responder
gets a &lt;a href=&#34;http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/events/ResultEvent.html&#34;&gt;ResultEvent&lt;/a&gt; and other times it gets the actual result. And then
there are the half million events you can listen for (and remember to remove
your event listeners for!). And... Well, if you&#39;ve spent any time in
ActionScript, I don&#39;t need to say any more.&lt;/p&gt;
&lt;p&gt;But I&#39;m not (usually) one to complain without offering a solution.&lt;/p&gt;
&lt;p&gt;So let me present: &lt;strong&gt;&lt;a href=&#34;http://bitbucket.org/wolever/as3-4house/src/tip/src/utils/async/AsyncResult.as&#34;&gt;AsyncResult&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In the simplest case - only handling a result / error - it looks something like
this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;UserService.loadUser(userID).complete(function(user:User):void {
    // ... do stuff with the User ...
}, function(error:AsyncError):void {
    // ... handle the error ...
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But that&#39;s not what makes AsyncResult cool.&lt;/p&gt;
&lt;p&gt;Imagine, for a minute, what that &lt;code&gt;UserService.loadUser&lt;/code&gt; function would look
like. Maybe it fires off a request to a server which sends back some JSON,
which is then loaded into an instance of User then returned. Pretty
straightforward... Except it probably takes a small army of event listeners,
callbacks and error handlers (which all need to be documented and tested and
maintained and...).&lt;/p&gt;
&lt;p&gt;This is the kind of situation which AsyncResult was designed for. Check it out:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public function loadUser(userID:String):AsyncResult {
    var token:AsyncToken;
    var result:AsyncResult = new AsyncResult();
    // (HTTP transaction intentionally simplified)
    token = HTTPService.sendGET(&#34;http://.../users/&#34; + userID);
    // The AsyncToken is plugged into the Flex AsyncToken
    // through &#39;getResponder()&#39;
    token.addResponder(result.getResponder());

    // &lt;b&gt;This is where the magic happens:&lt;/b&gt;
    result.complete(function(jsonData:String):User {
        var userData:Object = JSON.loads(jsonData);
        var user:User = User.loadFromObject(userData);
        return user;
    });

    return result;
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Two things to notice about the above code: first, the &lt;code&gt;complete&lt;/code&gt; callback
accepts JSON data (not an event) and, more importantly, returns an instance of
&lt;code&gt;User&lt;/code&gt;.  Second, no error handling is done.&lt;/p&gt;
&lt;p&gt;This is possible because AsyncToken chains all of its handlers. When a result
(or error) is received, it is passed to the first handler. If that handler
returns a new value (that is, something other than &lt;code&gt;undefined&lt;/code&gt;), that new value
is passed to the next handler, and so on.&lt;/p&gt;
&lt;p&gt;For example, this is what happens if the complete handlers &lt;code&gt;add1&lt;/code&gt; and &lt;code&gt;add2&lt;/code&gt;
are used:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; function add1(x) { return x + 1};
&amp;gt;&amp;gt;&amp;gt; function add2(x) { return x + 2};
&amp;gt;&amp;gt;&amp;gt; function printx(x) { trace(&#34;got:&#34;, x); };
&amp;gt;&amp;gt;&amp;gt; r = new AsyncResult();
&amp;gt;&amp;gt;&amp;gt; r.complete(printx);
&amp;gt;&amp;gt;&amp;gt; r.complete(add1);
&amp;gt;&amp;gt;&amp;gt; r.complete(printx);
&amp;gt;&amp;gt;&amp;gt; r.complete(add2);
&amp;gt;&amp;gt;&amp;gt; r.complete(printx);
&amp;gt;&amp;gt;&amp;gt; r.gotResult(0)
got: 0
got: 1
got: 3
&amp;gt;&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In addition, if any of the handlers return an AsyncResult, the original
AsyncResult will wait for the new AsyncResult to complete, then pass the new
result to the next handler.&lt;/p&gt;
&lt;p&gt;For example, going back to the &lt;code&gt;User&lt;/code&gt; example, imagine that we need a (slightly
contrived) &lt;code&gt;loadFavoritesForUserID(userID:String)&lt;/code&gt; function. It could look
something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;function loadFavoritesForUserID(userID:String):AsyncResult {
    var result:AsyncResult = UserService.loadUser(userID);
    result.complete(function(user:User):AsyncResult {
        var token:AsyncToken;
        token = = HTTPService.httpGET(user.getFavoritesURL());
        token.addResponder(result.getResponder());
        return result;
    });
    result.complete(function(jsonData:String):Array {
        return JSON.loads(jsonData);
    });
    return result;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Well, that&#39;s a short introduction to my awesome AsyncResult. If you&#39;re interested, check out &lt;a href=&#34;http://bitbucket.org/wolever/as3-4house/src/tip/src/utils/async/AsyncResult.as&#34;&gt;the code&lt;/a&gt; and hit me up on Twitter, &lt;a href=&#34;http://twitter.com/wolever&#34;&gt;@wolever&lt;/a&gt;. And if you&#39;re not interested, let me know why in the comments.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <author>
      <name>David Wolever</name>
      <uri>http://blog.codekills.net</uri>
    </author>
    <title type="html">A Parameterized Testrunner for FlexUnit</title>
    <link rel="alternate" type="text/html" href="http://blog.codekills.net/2010/02/10/a-parameterized-testrunner-for-flexunit" />
    <id>http://blog.codekills.net/2010/02/10/a-parameterized-testrunner-for-flexunit</id>
    <updated>2010-02-10T15:54:00Z</updated>
    <published>2010-02-10T15:54:00Z</published>
    <category scheme="http://blog.codekills.net" term="ActionScript" />
    <summary type="html">A Parameterized Testrunner for FlexUnit</summary>
    <content type="html" xml:base="http://blog.codekills.net/2010/02/10/a-parameterized-testrunner-for-flexunit">

&lt;p&gt;A couple of days ago, I &lt;a href=&#34;http://blog.codekills.net/archives/77-FlexUnits-Test-Theories-Dont-Bother.html&#34;&gt;complained about FlexUnit&#39;s Theories&lt;/a&gt;. Well, with a bit of encouragement from &lt;a href=&#34;http://twitter.com/drewbourne&#34;&gt;@drewbourne&lt;/a&gt;, I broke down and wrote a proper parameterized testrunner:&lt;/p&gt;
&lt;pre style=&#34;margin-top: -1.5em&#34;&gt;&lt;code&gt;
    [RunWith(&#34;utils.testrunners.ParameterizedRunner&#34;)]
    class AdditionTests {
        public static var numbersToTest:Array = [
            [1, 2, 3],
            [4, 5, 9],
            [-1, 1, 0]
        };

        [Parameterized(&#34;numbersToTest&#34;)]
        public function testAddition(a:int, b:int, expected:int):void {
            assertEqual(a+b, expected);
        }
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And that code will do exactly what you&#39;d expect: run three test cases, one for each of the inputs. If one test fails, the others will still run. Helpful error messages will be provided when a test fails.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;source can be downloaded&lt;/strong&gt; from: &lt;a href=&#34;http://gist.github.com/299871&#34;&gt;http://gist.github.com/299871&lt;/a&gt; &lt;small&gt;(and it will be getting a new home when ever I get around to releasing all of my AS utilities)&lt;/small&gt;&lt;/p&gt;
&lt;p&gt;Look useful? Give it a try and tell me what you think – I&#39;d love to know.&lt;/p&gt;
&lt;h2&gt;Update&lt;/h2&gt;
&lt;p&gt;Since this article was written, parameterized tests have been added to FlexUnit core. The documentation is over on the FlexUnit wiki: &lt;a href=&#34;http://docs.flexunit.org/index.php?title=Parameterized_Test_Styles&#34;&gt;http://docs.flexunit.org/index.php?title=Parameterized_Test_Styles&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And this is the above test, using the FlexUnit syntax:&lt;/p&gt;
&lt;pre style=&#34;margin-top: -1.5em&#34;&gt;&lt;code&gt; 
    [RunWith(&#34;org.flexunit.runners.Parameterized&#34;)]
    public class AdditionTests {        

        public static var numbersToTest:Array = [
            [1, 2, 3],
            [4, 5, 9],
            [-1, 1, 0]
        };


        [Test(dataProvider=&#34;numbersToTest&#34;)]
        public function testAddition(a:int, b:int, expected:int):void {
            assertEqual(a+b, expected);
        }
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <author>
      <name>David Wolever</name>
      <uri>http://blog.codekills.net</uri>
    </author>
    <title type="html">FlexUnit&#39;s Test Theories: Don&#39;t Bother</title>
    <link rel="alternate" type="text/html" href="http://blog.codekills.net/2010/02/05/flexunit's-test-theories--don't-bother" />
    <id>http://blog.codekills.net/2010/02/05/flexunit's-test-theories--don't-bother</id>
    <updated>2010-02-05T23:47:00Z</updated>
    <published>2010-02-05T23:47:00Z</published>
    <category scheme="http://blog.codekills.net" term="ActionScript" />
    <summary type="html">FlexUnit&#39;s Test Theories: Don&#39;t Bother</summary>
    <content type="html" xml:base="http://blog.codekills.net/2010/02/05/flexunit's-test-theories--don't-bother">

&lt;p&gt;I&#39;ve just been playing around with FlexUnit 4&#39;s nifty new &#34;Test Theories&#34;… And I have come to the conclusion that, right now, they are basically worthless.&lt;/p&gt;
&lt;p&gt;Here&#39;s why:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;They aren&#39;t documented. At all. There are approximately two examples on the internet, and the &lt;a href=&#34;http://docs.flexunit.org/index.php?title=Theory&#34;&gt;wiki page&lt;/a&gt; is a joke. Nothing explains what algorithm is used to calculate which &lt;a href=&#34;http://docs.flexunit.org/index.php?title=DataPoint&#34;&gt;DataPoints&lt;/a&gt; are applied to which theories.&lt;/li&gt;
&lt;li&gt;They make test error messages &lt;em&gt;less&lt;/em&gt; helpful. If a a theory fails, instead of getting a helpful error message like &#34;&lt;tt&gt;Theory `checkUrl(&#34;this is a bad url&#34;)` failed with message: could not determine protocol&lt;/tt&gt;&#34;, it gives a message like this: &#34;&lt;tt&gt;checkUrl urls[1]&lt;/tt&gt;&#34;. Yea, thanks guys.&lt;/li&gt;
&lt;li&gt;They don&#39;t do anything &#34;cool&#34;. At all. It would be cool if, given five data points, five distinct tests would be generated. It would be cool if one data point could fail while others succeed. Heck, anything which would make them better than a &lt;tt&gt;for&lt;/tt&gt; loop would be cool. But, alas…&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, don&#39;t waste your time on Theories just yet. For now, just use a &lt;code&gt;for&lt;/code&gt; loop:&lt;/p&gt;
&lt;pre style=&#34;margin-left: 3em; margin-top: -1em; margin-bottom: 1em&#34;&gt;&lt;code&gt;
[Test]
public function runTestsOnData():void {
    for each (datum in testData)
        doSomeTest(datum);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or, if you want to test the &lt;a href=&#34;http://en.wikipedia.org/wiki/Cartesian_product&#34;&gt;cartesian product&lt;/a&gt; of a set of data, use &lt;a href=&#34;http://gist.github.com/296418&#34;&gt;my handy cartesian product function&lt;/a&gt;:&lt;/p&gt;
&lt;pre style=&#34;margin-left: 3em; margin-top: -1em; margin-bottom: 1em&#34;&gt;&lt;code&gt;
[Test]
public function runTestsOnCartesianProduct():void {
    for each (data in cartesian_product(testData0, testData1))
        doSomeTest.apply(this, data);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Followup&lt;/strong&gt;: as Alan (see comments) said, what I really want is a parameterized testrunner. So I&#39;ve gone ahead and written one. See &lt;a href=&#34;http://blog.codekills.net/archives/79-A-Parameterized-Testrunner-for-FlexUnit.html&#34;&gt;my post on a Parameterized Testrunner for FlexUnit&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <author>
      <name>David Wolever</name>
      <uri>http://blog.codekills.net</uri>
    </author>
    <title type="html">Best Ever Implementation of &#34;indexOf&#34;!</title>
    <link rel="alternate" type="text/html" href="http://blog.codekills.net/2009/12/07/best-ever-implementation-of--indexof-!" />
    <id>http://blog.codekills.net/2009/12/07/best-ever-implementation-of--indexof-!</id>
    <updated>2009-12-08T03:31:00Z</updated>
    <published>2009-12-08T03:31:00Z</published>
    <category scheme="http://blog.codekills.net" term="ActionScript" />
    <summary type="html">Best Ever Implementation of &#34;indexOf&#34;!</summary>
    <content type="html" xml:base="http://blog.codekills.net/2009/12/07/best-ever-implementation-of--indexof-!">

&lt;p&gt;(alternate title: &lt;em&gt;The &#34;Fail Early, Fail Often&#34; Principle in Action&lt;/em&gt;)&lt;/p&gt;
&lt;p&gt;I would like to award Adobe the &#34;best ever implementation of &lt;code&gt;indexOf&lt;/code&gt;&#34;. Ready for it? Here it is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;override flash_proxy function callProperty(name:*, ... rest):* {
    return null;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This beauty can be found in &lt;code&gt;mx.collections.ListCollectionView&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;And the kicker? The function&#39;s documentation:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/**
 *  @private
 *  Any methods that can&#39;t be found on this class shouldn&#39;t be called,
 *  so return null
 */
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The author clearly knew that unknown methods* shouldn&#39;t be called… But instead of doing something sensible – like throwing an exception – they do something wholly nonsensical and return &lt;code&gt;null&lt;/code&gt;. Or, of course, they could also have left the function unimplemented, which would result in a strange and unhelpful exception… But, of course, I would expect nothing but the best from the Flex standard library.&lt;/p&gt;
&lt;p&gt;Next up: why implicit conversions from &lt;code&gt;null&lt;/code&gt; to &lt;code&gt;int&lt;/code&gt; are always wrong.&lt;/p&gt;
&lt;p&gt;&amp;lt;/rant&amp;gt;&lt;/p&gt;
&lt;p&gt;*: the magic &lt;code&gt;callProperty&lt;/code&gt; method is called on subclasses of &lt;code&gt;Proxy&lt;/code&gt; when a method can&#39;t be found. For example if &lt;code&gt;bar&lt;/code&gt; is not a method of &lt;code&gt;foo&lt;/code&gt;, executing &lt;code&gt;foo.bar()&lt;/code&gt;will call &lt;code&gt;foo.callProperty(&#34;bar&#34;)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;PS: Instead of calling &lt;code&gt;indexOf&lt;/code&gt;, I should have been calling &lt;code&gt;getItemIndex&lt;/code&gt;.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <author>
      <name>David Wolever</name>
      <uri>http://blog.codekills.net</uri>
    </author>
    <title type="html">Making Flex&#39;s PopUpMenuButton More Helpful</title>
    <link rel="alternate" type="text/html" href="http://blog.codekills.net/2009/08/25/making-flex's-popupmenubutton-more-helpful" />
    <id>http://blog.codekills.net/2009/08/25/making-flex's-popupmenubutton-more-helpful</id>
    <updated>2009-08-25T22:09:00Z</updated>
    <published>2009-08-25T22:09:00Z</published>
    <category scheme="http://blog.codekills.net" term="ActionScript" />
    <summary type="html">Making Flex&#39;s PopUpMenuButton More Helpful</summary>
    <content type="html" xml:base="http://blog.codekills.net/2009/08/25/making-flex's-popupmenubutton-more-helpful">

&lt;p&gt;If you&#39;re anything like me, you cringe every time you think about implementing a popup menu in Flex: the options, &lt;code&gt;PopUpButton&lt;/code&gt; and &lt;code&gt;PopUpMenuButton&lt;/code&gt;, are both terrible.&lt;/p&gt;
&lt;p&gt;For example, &lt;code&gt;PopUpButton&lt;/code&gt; makes you jump through the hoops of creating a &lt;code&gt;Menu&lt;/code&gt; and &lt;code&gt;PopUpMenuButton&lt;/code&gt; forces you to create an event handler just to get the currently selected item.&lt;/p&gt;
&lt;p&gt;Well, cringe no more! I&#39;ve done a bit of hacking on the &lt;code&gt;PopUpMenuButton&lt;/code&gt; to make the most common use-case, &#34;showing a list of options&#34;, a little bit less painful by adding a &#39;selectedItem&#39; field:&lt;/p&gt;
&lt;pre style=&#34;color:#000000;&#34;&gt;    &lt;span style=&#34;color:#a65700; &#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#666616; &#34;&gt;mx&lt;/span&gt;&lt;span style=&#34;color:#800080; &#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#5f5035; &#34;&gt;XML&lt;/span&gt; &lt;span style=&#34;color:#274796; &#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;colors&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#a65700; &#34;&gt;&gt;&lt;/span&gt;
        &lt;span style=&#34;color:#a65700; &#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#5f5035; &#34;&gt;colors&lt;/span&gt;&lt;span style=&#34;color:#a65700; &#34;&gt;&gt;&lt;/span&gt;
            &lt;span style=&#34;color:#a65700; &#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#5f5035; &#34;&gt;color&lt;/span&gt; &lt;span style=&#34;color:#274796; &#34;&gt;name&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;Red&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt; &lt;span style=&#34;color:#274796; &#34;&gt;rgb&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;0xFF0000&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt; &lt;span style=&#34;color:#a65700; &#34;&gt;/&gt;&lt;/span&gt;
            &lt;span style=&#34;color:#a65700; &#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#5f5035; &#34;&gt;color&lt;/span&gt; &lt;span style=&#34;color:#274796; &#34;&gt;name&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;Green&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt; &lt;span style=&#34;color:#274796; &#34;&gt;rgb&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;0x00FF00&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt; &lt;span style=&#34;color:#a65700; &#34;&gt;/&gt;&lt;/span&gt;
            &lt;span style=&#34;color:#a65700; &#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#5f5035; &#34;&gt;color&lt;/span&gt; &lt;span style=&#34;color:#274796; &#34;&gt;name&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;Blue&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt; &lt;span style=&#34;color:#274796; &#34;&gt;rgb&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;0x0000FF&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt; &lt;span style=&#34;color:#a65700; &#34;&gt;/&gt;&lt;/span&gt;
        &lt;span style=&#34;color:#a65700; &#34;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#34;color:#5f5035; &#34;&gt;colors&lt;/span&gt;&lt;span style=&#34;color:#a65700; &#34;&gt;&gt;&lt;/span&gt;
    &lt;span style=&#34;color:#a65700; &#34;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#34;color:#666616; &#34;&gt;mx&lt;/span&gt;&lt;span style=&#34;color:#800080; &#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#5f5035; &#34;&gt;XML&lt;/span&gt;&lt;span style=&#34;color:#a65700; &#34;&gt;&gt;&lt;/span&gt;
    
    &lt;span style=&#34;color:#a65700; &#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#5f5035; &#34;&gt;HelpfulPopupMenu&lt;/span&gt; &lt;span style=&#34;color:#274796; &#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;colorMenu&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;
        &lt;span style=&#34;color:#274796; &#34;&gt;dataProvider&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;{colors}&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;
        &lt;span style=&#34;color:#274796; &#34;&gt;labelField&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;@name&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;
        &lt;span style=&#34;color:#274796; &#34;&gt;showRoot&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;false&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt; &lt;span style=&#34;color:#a65700; &#34;&gt;/&gt;&lt;/span&gt;

    &lt;span style=&#34;color:#a65700; &#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#666616; &#34;&gt;mx&lt;/span&gt;&lt;span style=&#34;color:#800080; &#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#5f5035; &#34;&gt;Label&lt;/span&gt;
        &lt;span style=&#34;color:#274796; &#34;&gt;color&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;{XML(colorMenu.selectedItem).@rgb}&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;
        &lt;span style=&#34;color:#274796; &#34;&gt;text&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;You&#39;ve chosen: {XML(colorMenu.selectedItem).@name}&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt; &lt;span style=&#34;color:#a65700; &#34;&gt;/&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Which can also be used to set a temporary default option:&lt;/p&gt;
&lt;pre style=&#34;color:#000000;&#34;&gt;    &lt;span style=&#34;color:#a65700; &#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#666616; &#34;&gt;mx&lt;/span&gt;&lt;span style=&#34;color:#800080; &#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#5f5035; &#34;&gt;Script&lt;/span&gt;&lt;span style=&#34;color:#a65700; &#34;&gt;&gt;&lt;/span&gt;&lt;span style=&#34;color:#606060; &#34;&gt;&amp;lt;![CDATA[&lt;/span&gt;
        var people:Array = [
            { name: &#34;Bob&#34;, age: 16 },
            { name: &#34;Alice&#34;, age: 42 },
            { name: &#34;Jo&#34;, age: 31 }
        ];
        
    &lt;span style=&#34;color:#606060; &#34;&gt;]]&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#a65700; &#34;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#34;color:#666616; &#34;&gt;mx&lt;/span&gt;&lt;span style=&#34;color:#800080; &#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#5f5035; &#34;&gt;Script&lt;/span&gt;&lt;span style=&#34;color:#a65700; &#34;&gt;&gt;&lt;/span&gt;
    
    &lt;span style=&#34;color:#a65700; &#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#5f5035; &#34;&gt;HelpfulPopupMenu&lt;/span&gt; &lt;span style=&#34;color:#274796; &#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;peopleMenu&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;
        &lt;span style=&#34;color:#274796; &#34;&gt;dataProvider&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;{people}&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;
        &lt;span style=&#34;color:#274796; &#34;&gt;labelField&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;name&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;
        &lt;span style=&#34;color:#274796; &#34;&gt;selectedItem&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;{ { name: &#39;(select a person)&#39;, age: null } }&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;
        &lt;span style=&#34;color:#274796; &#34;&gt;showRoot&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;false&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt; &lt;span style=&#34;color:#a65700; &#34;&gt;/&gt;&lt;/span&gt;

    &lt;span style=&#34;color:#a65700; &#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#666616; &#34;&gt;mx&lt;/span&gt;&lt;span style=&#34;color:#800080; &#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#5f5035; &#34;&gt;Label&lt;/span&gt;
        &lt;span style=&#34;color:#274796; &#34;&gt;visible&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;{ peopleMenu.selectedItem.age !== null }&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;
        &lt;span style=&#34;color:#274796; &#34;&gt;text&lt;/span&gt;&lt;span style=&#34;color:#808030; &#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;That person is { peopleMenu.selectedItem.age } years old.&lt;/span&gt;&lt;span style=&#34;color:#0000e6; &#34;&gt;&#34;&lt;/span&gt; &lt;span style=&#34;color:#a65700; &#34;&gt;/&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Useful? I&#39;d like to hope so.&lt;/p&gt;
&lt;p&gt;You can see a demo by clicking the image below (sorry, I don&#39;t actually know the first thing about embedding SWFs into HTML, and I don&#39;t feel up to learning right now):&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;http://wolever.net/~wolever/HelpfulPopupMenu/example/&#34;&gt;&lt;img src=&#34;http://img.skitch.com/20090825-g69br4c43ebm3a2ut7mudf7pik.png&#34; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And you can download the source (which is MIT licensed) from more or less the same place: &lt;a href=&#34;http://wolever.net/~wolever/HelpfulPopupMenu/&#34;&gt;http://wolever.net/~wolever/HelpfulPopupMenu/&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Also, this is a small part of a larger library of helpful ActionScript utilities which I&#39;m going to be releasing… At some point.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <author>
      <name>David Wolever</name>
      <uri>http://blog.codekills.net</uri>
    </author>
    <title type="html">Using Hamcrest to Filter ArrayCollections</title>
    <link rel="alternate" type="text/html" href="http://blog.codekills.net/2009/08/11/using-hamcrest-to-filter-arraycollections" />
    <id>http://blog.codekills.net/2009/08/11/using-hamcrest-to-filter-arraycollections</id>
    <updated>2009-08-11T16:03:00Z</updated>
    <published>2009-08-11T16:03:00Z</published>
    <category scheme="http://blog.codekills.net" term="ActionScript" />
    <summary type="html">Using Hamcrest to Filter ArrayCollections</summary>
    <content type="html" xml:base="http://blog.codekills.net/2009/08/11/using-hamcrest-to-filter-arraycollections">

&lt;p&gt;&lt;a href=&#34;http://twitter.com/nwebb&#34;&gt;Neil Webb&#39;s&lt;/a&gt; post on &lt;a href=&#34;http://nwebb.co.uk/blog/?p=371&#34;&gt;filtering an ArrayCollection on multiple property/values&lt;/a&gt; reminded me of how I recently solved exactly the same problem using &lt;a href=&#34;http://github.com/drewbourne/hamcrest-as3/tree/master&#34;&gt;Hamcrest-AS3&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So, you know the story: you&#39;ve got an &lt;code&gt;ArrayCollection&lt;/code&gt; that&#39;s full of, say, &lt;code&gt;Laptop&lt;/code&gt;s, and you want to filter it by, say, price, size and (of course) color.&lt;/p&gt;
&lt;p&gt;Because you&#39;re a good programmer you always try to &lt;a href=&#34;http://c2.com/xp/DoTheSimplestThingThatCouldPossiblyWork.html&#34;&gt;do the simplest thing that could possibly work&lt;/a&gt; first, and end up with a function something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;function laptopFilter(laptop:Laptop):Boolean {
    if (laptop.price &amp;gt; appliedFilters.maxPrice)
        return false;

    if (laptop.size &amp;gt; appliedFilters.maxSize)
        return false;

    if (laptop.color != appliedFilters.preferredColor)
        return false;

    return true;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cool - that defiantly works, and it&#39;s pretty simple.&lt;/p&gt;
&lt;p&gt;&#34;But wait a second&#34;, you&#39;re thinking, &#34;what happens when the rules get more complex? That function is quickly going to loose its simplicity!&#34;&lt;/p&gt;
&lt;p&gt;Enter, &lt;a href=&#34;http://code.google.com/p/hamcrest/&#34;&gt;Hamcrest&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Hamcrest is a library of &#34;matchers&#34; which are often used to build unit tests. Here is a quick example of a unit test written with Hamcrest:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[Test]
function testApplePicker():void {
    var apples:Array = ApplePicker.pick(&#34;granny smith&#34;);
    assertThat(apples.length, greaterThan(4));
    assertThat(apples, everyItem(hasPropery(&#34;color&#34;, &#34;green&#34;)));
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But, of course, there is no reason that these same matchers shouldn&#39;t be used for other things too.&lt;/p&gt;
&lt;p&gt;Other things like, say, filtering an ArrayCollection:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;var filters:Array = [
    hasProperty(&#34;price&#34;, greaterThan(1000)),
    hasProperty(&#34;color&#34;, either(&#34;red&#34;).or(&#34;blue&#34;).or(&#34;green&#34;)),
    hasProperty(&#34;size&#34;, between(10, 15))
];

var laptopFilter(laptop:Laptop):Boolean {
    return allOf.apply(null, filters).match(laptop);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Of course, I&#39;ve hard-coded the values in this example, but it doesn&#39;t take much creativity to imagine how they could be dynamically generated, keeping the code nice and simple while still allowing for complex rules.&lt;/p&gt;
&lt;p&gt;So, that&#39;s how I filter ArrayCollections &lt;img src=&#34;/templates/default/img/emoticons/smile.png&#34; alt=&#34;:-)&#34; style=&#34;display: inline; vertical-align: bottom;&#34; class=&#34;emoticon&#34; /&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <author>
      <name>David Wolever</name>
      <uri>http://blog.codekills.net</uri>
    </author>
    <title type="html">Overriding private methods in ActionScript, the hard way</title>
    <link rel="alternate" type="text/html" href="http://blog.codekills.net/2009/07/10/overriding-private-methods-in-actionscript,-the-hard-way" />
    <id>http://blog.codekills.net/2009/07/10/overriding-private-methods-in-actionscript,-the-hard-way</id>
    <updated>2009-07-10T14:49:00Z</updated>
    <published>2009-07-10T14:49:00Z</published>
    <category scheme="http://blog.codekills.net" term="ActionScript" />
    <summary type="html">Overriding private methods in ActionScript, the hard way</summary>
    <content type="html" xml:base="http://blog.codekills.net/2009/07/10/overriding-private-methods-in-actionscript,-the-hard-way">

&lt;p&gt;Are you working with a proprietary &lt;code&gt;.swc&lt;/code&gt;? Does it have lots of bugs? Did the authors, in all their infinite wisdom, decide to hide those bugs in &lt;code&gt;private&lt;/code&gt; methods, so you stand no chance of being able to fix them?  Well, friend, let me show you how to fix that.&lt;/p&gt;

&lt;!-- EXTENDED BODY --&gt;
&lt;a id=&#34;extended&#34;&gt;&lt;/a&gt;&lt;h2&gt;Step 0: Uncompressing the &lt;code&gt;swc&lt;/code&gt;/&lt;code&gt;swf&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;First make a backup copy of the library (just incase you botch something):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; $ cp binary_library.swc binary_library_backup.swc
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then unzip the &lt;code&gt;swc&lt;/code&gt; file like you would any other &lt;code&gt;zip&lt;/code&gt; file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; $ unzip binary_library.swc
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will extract, among other things, a &lt;code&gt;library.swf&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;This &lt;code&gt;library.swf&lt;/code&gt; will probably be compressed, so you&#39;ve also got to uncompress it. To do that, I like to use &lt;a href=&#34;http://www.swftools.org/&#34;&gt;SWFTOOLS&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; $ swfcombine -d library.swf -o uncompressed_library.swf
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Step 1: Dumping the ABC&lt;/h2&gt;
&lt;p&gt;Now that you&#39;ve got a nice uncompressed &lt;code&gt;swf&lt;/code&gt;, it&#39;s time to decompile it. To do this, you can use or my patched version of &lt;a href=&#34;http://wolever.net/~wolever/wiki/swfutil/&#34;&gt;swfdump&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; $ java -jar swfdump.jar -abc library.swf &amp;gt; library.abc
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Step 2: Finding the multiname pool entry&lt;/h2&gt;
&lt;p&gt;Now pull up &lt;code&gt;library.abc&lt;/code&gt; in your favorite text editor and search for the method&#39;s name under the &#34;MultiName Constant Pool Entries&#34; heading.  For example, if the method&#39;s name is &#34;priv&#34;, you&#39;ll be looking for something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;6 MultiName Constant Pool Entries
07 01 04 private:priv &amp;lt;-- here
07 02 06 :void
07 02 09 :pub
07 02 01 :A
07 02 10 :Object
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the method may be prefixed with a namespace:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;6 MultiName Constant Pool Entries
...
07 01 04 com.foo.ClassName:methodName
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Technical details&lt;/strong&gt;: The first of those three bytes refers to the entry kind. The second is a one-based index into the list of namespaces (which are listed under &#34;Namespace Constant Pool Entries&#34;) and the third is a one-based index into the list of string constants (&#34;String Constant Pool Entries&#34;).  For all the details, see section &#34;4.3 Constant Pool&#34;, &#34;4.4.3 Multiname&#34; and &#34;4.1 Primitive data types&#34; (for the definition of u30 – making sure to read the paragraph witch mentions that it uses little-endian byte order) in &lt;a href=&#34;http://www.adobe.com/devnet/actionscript/articles/avm2overview.pdf&#34;&gt;AVM 2 Machine Overview&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note: If you&#39;re dealing with a large &lt;code&gt;.swf&lt;/code&gt;, there may be four or even five bytes:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;07 01 B9 03 :methodName
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Don&#39;t worry – that&#39;s ok!&lt;/p&gt;
&lt;p&gt;Make note of the bytes (in this case, &lt;code&gt;07 01 04&lt;/code&gt;) which prefix the method, then move on to step 3.&lt;/p&gt;
&lt;h2&gt;Step 3: Find a similar method&lt;/h2&gt;
&lt;p&gt;Next thing you&#39;ve got to do is find a method of the &lt;strong&gt;same class&lt;/strong&gt; which has a pubic (or protected) scope.  In this case, we have a method called &#39;pub&#39;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;6 MultiName Constant Pool Entries
07 01 04 private:priv
07 02 06 :void
07 02 09 :pub &amp;lt;-- here
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Make note here of the byte (&lt;code&gt;02&lt;/code&gt;): that tells the AVM which namespace the method belongs to.&lt;/p&gt;
&lt;h2&gt;Step 4: Hex edit the uncompressed library&lt;/h2&gt;
&lt;p&gt;Now, pull up your &lt;a href=&#34;http://ridiculousfish.com/hexfiend/&#34;&gt;favorite hex editor&lt;/a&gt; and open up the &lt;code&gt;uncompressed_library.swf&lt;/code&gt;, which you created in step 0. Now, remember those bytes which prefix the method name? Search for them (and make sure you only find one instance of them – if there are multiple instances of them, expand the search to take into account the next few bytes (so, in this case, &lt;code&gt;07 01 04 07 02 06&lt;/code&gt;).  Now, once you&#39;ve found them, simply replace the second byte (in this case &lt;code&gt;01&lt;/code&gt;) with the second byte of the similar method:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;07 01 04
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;is replaced with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;07 02 04
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Step 5: Checking that you got it right&lt;/h2&gt;
&lt;p&gt;To check and make sure that you got it right, run the &lt;code&gt;swfutil&lt;/code&gt; again, then check the output:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ java -jar swfdump.jar -abc uncompressed_library.swc
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You should see your change reflected in the MultiName constant pool entries:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;6 MultiName Constant Pool Entries
07 02 04 :priv
07 02 06 :void
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the method is no longer prefixed with &#39;private&#39; (or whatever the original namespace was).&lt;/p&gt;
&lt;p&gt;Now, if the utility crashes, or something else doesn&#39;t work, go back and try again – you&#39;ll get it eventually.&lt;/p&gt;
&lt;h2&gt;Step 6: Putting it all back together&lt;/h2&gt;
&lt;p&gt;You&#39;re almost done!  All that&#39;s left to do is put everything back into the &lt;code&gt;.swc&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;First, copy &lt;code&gt;uncompressed_library.swf&lt;/code&gt; over top of &lt;code&gt;library.swf&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ cp library_uncompressed.swf library.swf
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or, optionally, you can re-compress it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ swfcombine -z -d library_uncompressed.swf -o library.swf
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then put &lt;code&gt;library.swf&lt;/code&gt; back into the &lt;code&gt;swc&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ zip binary_library.swc library.swf
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally try linking against it to see if everything worked!&lt;/p&gt;
&lt;p&gt;See also:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://code.google.com/p/erlswf/&#34;&gt;erlswf&lt;/a&gt; – has a much prettier ABC dump.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://www.adobe.com/devnet/actionscript/articles/avm2overview.pdf&#34;&gt;AVM 2 Machine Overview&lt;/a&gt; – keep this under your pillow.&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
</feed>

