<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" gd:etag="W/&quot;CUICQHY9eyp7ImA9WhJTEk0.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740</id><updated>2012-06-21T00:46:01.863+10:00</updated><category term="Frameworks" /><category term="Smartypants" /><category term="FAQ" /><category term="tools" /><category term="workflow" /><category term="Dependency Injection" /><category term="skinning" /><category term="degrafa" /><category term="design" /><category term="IOC" /><category term="actionscript" /><category term="utils" /><category term="flex" /><category term="update" /><category term="barra" /><category term="enums" /><title>Flex and the City</title><subtitle type="html">Tales of Adobe Flex Development from Brisbane, Australia</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Josh McDonald</name><uri>http://www.blogger.com/profile/16442649328289782363</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/_ht3yWCqt7ac/ShNYmrF7MVI/AAAAAAAAAB0/akAX--H-xEs/S220/Photo+9.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>29</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/FlexAndTheCity" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="flexandthecity" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DkMASHs_eyp7ImA9WxJVFUw.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-8883993439382418928</id><published>2009-07-02T15:34:00.002+10:00</published><updated>2009-07-02T16:00:49.543+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-02T16:00:49.543+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="skinning" /><category scheme="http://www.blogger.com/atom/ns#" term="update" /><title>A quick update</title><content type="html">&lt;p&gt;Updates:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;The &lt;a href="http://code.google.com/p/tickertape/" title="tickertape - Google Code"&gt;Degrafa Skin&lt;/a&gt; project is progressing. I've added a skin for Application, which shows off a few nice features of &lt;a href="http://degrafa.org/" title="Degrafa : Declarative Graphics Framework"&gt;Degrafa&lt;/a&gt;. I'll be blogging about this soon.&lt;/li&gt;

&lt;li&gt;I've been doing quite a bit of work with BlazeDS recently, and the experience is nowhere near as pleasant as it should be. 
    More to come on this front over the next couple of months.&lt;/li&gt;

&lt;li&gt;As usual, I've been hacking Degrafa, although not as often as I'd like. I'll be committing the Filters package in the next few days, and 
I'll blog about it again with more details. I'll also be checking in support for Ant soon as well.&lt;/li&gt;
&lt;/ul&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/8883993439382418928/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=8883993439382418928" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/8883993439382418928?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/8883993439382418928?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2009/07/quick-update.html" title="A quick update" /><author><name>Josh McDonald</name><uri>http://www.blogger.com/profile/16442649328289782363</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/_ht3yWCqt7ac/ShNYmrF7MVI/AAAAAAAAAB0/akAX--H-xEs/S220/Photo+9.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DU4GSHc-fip7ImA9WxJRF04.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-5628537687537119010</id><published>2009-05-19T22:55:00.001+10:00</published><updated>2009-05-19T22:58:49.956+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-19T22:58:49.956+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="flex" /><category scheme="http://www.blogger.com/atom/ns#" term="degrafa" /><category scheme="http://www.blogger.com/atom/ns#" term="skinning" /><title>A complete skin for Flex applications using Degrafa (part 1)</title><content type="html">&lt;h4&gt;Overview&lt;/h4&gt;

&lt;p&gt;I’ve been working with &lt;a href="http://degrafa.org/" title="Degrafa : Declarative Graphics Framework"&gt;Degrafa&lt;/a&gt; for a while now, using it to build new components and skin the old. I’ve fixed a few bugs, and contributed some new features, which will hopefully see light sooner rather than later. There’s a few blog posts and tutorials around the net on skinning various individual components, but nothing really comprehensive.&lt;/p&gt;

&lt;p&gt;To address this, I’ll be building a complete Flex skin using Degrafa, one component at a time through my blog. &lt;a href="http://code.google.com/p/tickertape/" title="tickertape - Google Code"&gt;Download the source code&lt;/a&gt; from Google code, and I’ll try to get a component a week added until the entire standard Flex 3 component set is thoroughly skinned.&lt;/p&gt;

&lt;p&gt;So with that out of the way, let’s begin, with TabNavigator!&lt;/p&gt;

&lt;h4&gt;TabNavigator&lt;/h4&gt;

&lt;p&gt;The core of any skin is of course, the &lt;a href="http://code.google.com/p/tickertape/source/browse/trunk/src/parade/parade.css" title="parade.css - tickertape - Google Code"&gt;CSS file&lt;/a&gt;. Here’s a snippet of what we’re interested in:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
TabNavigator
{
 border-skin:ClassReference(&amp;quot;&lt;a href="http://code.google.com/p/tickertape/source/browse/trunk/src/parade/TabNavigatorSkin.mxml" title="TabNavigatorSkin.mxml - tickertape - Google Code"&gt;parade.TabNavigatorSkin&lt;/a&gt;&amp;quot;);
 padding-top:0px;
 padding-right:0px;
 padding-bottom:0px;
 padding-left:0px;
 tabStyleName:&amp;quot;navigatorTab&amp;quot;;
 firstTabStyleName:&amp;quot;navigatorTab&amp;quot;;
 lastTabStyleName:&amp;quot;navigatorTab&amp;quot;;
 selectedTabTextStyleName:&amp;quot;selectedTabText&amp;quot;;
}

Button.navigatorTab
{
 skin:ClassReference(&amp;quot;&lt;a href="http://code.google.com/p/tickertape/source/browse/trunk/src/parade/TabSkin.mxml" title="TabSkin.mxml - tickertape - Google Code"&gt;parade.TabSkin&lt;/a&gt;&amp;quot;);
 paddingTop:1;
 paddingRight:10;
 paddingBottom:1;
 paddingLeft:10;
}
&lt;/pre&gt;

&lt;p&gt;As you can see, we’re referencing two custom skins: &lt;a href="http://code.google.com/p/tickertape/source/browse/trunk/src/parade/TabNavigatorSkin.mxml" title="TabNavigatorSkin.mxml - tickertape - Google Code"&gt;TabNavigatorSkin&lt;/a&gt; and &lt;a href="http://code.google.com/p/tickertape/source/browse/trunk/src/parade/TabSkin.mxml" title="TabSkin.mxml - tickertape - Google Code"&gt;TabSkin&lt;/a&gt;. One to skin the ViewStack.&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://code.google.com/p/tickertape/source/browse/trunk/src/parade/TabNavigatorSkin.mxml" title="TabNavigatorSkin.mxml - tickertape - Google Code"&gt;TabNavigator skin source code&lt;/a&gt; isn’t particularly exciting, so I won’t reproduce it here. The interesting part that will be new for a lot of readers, is the leveraging of &lt;a href="http://www.degrafa.org/docs/com/degrafa/states/package-detail.html" title="com.degrafa.states Summary"&gt;Degrafa’s new states support&lt;/a&gt;. Here’s the code in question, taken from &lt;a href="http://code.google.com/p/tickertape/source/browse/trunk/src/parade/TabSkin.mxml" title="TabSkin.mxml - tickertape - Google Code"&gt;TabSkin.mxml&lt;/a&gt;:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
&amp;lt;degrafa:states&amp;gt;
    
    &amp;lt;!-- Hover --&amp;gt;
    &amp;lt;degrafa:State name=&amp;quot;overSkin&amp;quot;&amp;gt;
        &amp;lt;degrafa:SetProperty target=&amp;quot;{mainFill}&amp;quot; name=&amp;quot;color&amp;quot; value=&amp;quot;#dddddd&amp;quot;/&amp;gt;
    &amp;lt;/degrafa:State&amp;gt;

    &amp;lt;!-- Selected --&amp;gt;
    &amp;lt;degrafa:State name=&amp;quot;selectedUpSkin&amp;quot;&amp;gt;
        &amp;lt;degrafa:SetProperty target=&amp;quot;{outlineShape}&amp;quot; name=&amp;quot;top&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;
        &amp;lt;degrafa:SetProperty target=&amp;quot;{notch}&amp;quot; name=&amp;quot;top&amp;quot; value=&amp;quot;1&amp;quot;/&amp;gt;
        &amp;lt;degrafa:SetProperty target=&amp;quot;{notch}&amp;quot; name=&amp;quot;visible&amp;quot; value=&amp;quot;true&amp;quot;/&amp;gt;
        &amp;lt;degrafa:SetProperty target=&amp;quot;{notchOutline}&amp;quot; name=&amp;quot;top&amp;quot; value=&amp;quot;1&amp;quot;/&amp;gt;
        &amp;lt;degrafa:SetProperty target=&amp;quot;{notchOutline}&amp;quot; name=&amp;quot;visible&amp;quot; value=&amp;quot;true&amp;quot;/&amp;gt;
        &amp;lt;degrafa:SetProperty target=&amp;quot;{fillShape}&amp;quot; name=&amp;quot;top&amp;quot; value=&amp;quot;1&amp;quot;/&amp;gt;
        &amp;lt;degrafa:SetProperty target=&amp;quot;{fillShape}&amp;quot; name=&amp;quot;bottom&amp;quot; value=&amp;quot;-2&amp;quot;/&amp;gt;
        &amp;lt;degrafa:SetProperty target=&amp;quot;{bling}&amp;quot; name=&amp;quot;top&amp;quot; value=&amp;quot;1&amp;quot;/&amp;gt;
        &amp;lt;degrafa:SetProperty target=&amp;quot;{bling}&amp;quot; name=&amp;quot;visible&amp;quot; value=&amp;quot;false&amp;quot;/&amp;gt;
        &amp;lt;degrafa:SetProperty target=&amp;quot;{mainFill}&amp;quot; name=&amp;quot;color&amp;quot; value=&amp;quot;#dddddd&amp;quot;/&amp;gt;
    &amp;lt;/degrafa:State&amp;gt;
    &amp;lt;degrafa:State name=&amp;quot;selectedOverSkin&amp;quot; basedOn=&amp;quot;selectedUpSkin&amp;quot;/&amp;gt;
    &amp;lt;degrafa:State name=&amp;quot;selectedDownSkin&amp;quot; basedOn=&amp;quot;selectedUpSkin&amp;quot;/&amp;gt;
    &amp;lt;degrafa:State name=&amp;quot;selectedDisabledSkin&amp;quot; basedOn=&amp;quot;selectedUpSkin&amp;quot;/&amp;gt;
    
&amp;lt;/degrafa:states&amp;gt;
&lt;/pre&gt;

&lt;p&gt;If this syntax looks familiar, it’s because it should - it’s based on the existing syntax you’re used to seeing to set up states in regular old MXML components.&lt;/p&gt;

&lt;p&gt;A key difference you should pay attention to is that in Degrafa the property that identifies the current selected state is &lt;strong&gt;not&lt;/strong&gt; "currentState", as with regular UIComponents. For Degrafa skins, it’s stored in the "name" field. This is because that’s the way the Halo component model is designed, and in 99% of cases it’s Halo components we’re skinning.&lt;/p&gt;

&lt;p&gt;The state names you see above are also just part of Halo’s way of doing things. They’re not consistent across different components, but that’s simply how it is. Adobe have no plans on changing the names to be more sensible, because they’re throwing out the whole thing for Spark, the component model and library that will be in &lt;a href="http://opensource.adobe.com/wiki/display/flexsdk/Gumbo" title="Gumbo - Flex SDK - Confluence"&gt;Flash Builder / Flex 4&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To see the skin in action, click the image below (view source enabled):&lt;/p&gt;

&lt;p align="center"&gt;&lt;a href="http://www.gfunk007.com/flexandthecity/parade/ParadeDemo.html" title=""&gt;&lt;img src="http://www.gfunk007.com/flexandthecity/parade/tabbar.png" alt="Application Skin example" border="0"/&gt;&lt;br/&gt;View the example app&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next week: Checkboxes! Do you have preferences as to which components you’d like to see examples for earlier than others? Email me, [catch me on Twitter], or leave a comment here on my blog.&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/5628537687537119010/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=5628537687537119010" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/5628537687537119010?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/5628537687537119010?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2009/05/complete-skin-for-flex-applications.html" title="A complete skin for Flex applications using Degrafa (part 1)" /><author><name>Josh McDonald</name><uri>http://www.blogger.com/profile/16442649328289782363</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/_ht3yWCqt7ac/ShNYmrF7MVI/AAAAAAAAAB0/akAX--H-xEs/S220/Photo+9.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkEDQXo6fSp7ImA9WxVUFEw.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-2663078107911472059</id><published>2009-03-18T22:17:00.002+10:00</published><updated>2009-03-19T08:17:50.415+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-19T08:17:50.415+10:00</app:edited><title>On using "if(foo)" vs "if(foo != null)"</title><content type="html">&lt;p&gt;I was going to leave this topic for a planned series of posts detailing (and explaining) my personal coding style, as it differs somewhat to that &lt;a href="http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions" title="Coding Conventions - Flex SDK - Confluence"&gt;laid out by Adobe&lt;/a&gt;. But, a few people noticed a &lt;a href="http://twitter.com/sophistifunk/status/1298404213" title="Twitter / Josh &amp;guot;G&amp;guot; McDonald: The ActionScript practice ..."&gt;comment I made&lt;/a&gt; about the subject, so I thought I'd rant on the subject here, where I can explain myself.&lt;/p&gt;

&lt;p&gt;Adobe's guidelines tell us that to test if foo is not null, we should use something like the following:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
if (foo)
    doSomething();
&lt;/pre&gt;

&lt;p&gt;This does work, and I find it makes for nice readable code. My coding style is based around readability and "pretty", so I do this &lt;strong&gt;all the time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;However, there are a lot of places where we're forced by ActionScript's limited overloading capabilities to declare method parameters as &lt;em&gt;Object&lt;/em&gt; or &lt;em&gt;*&lt;/em&gt;. And this is where bugs creep in.&lt;/p&gt;

&lt;p&gt;Let's say you have a method like so:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
public function doStuf(howMany : Number, usefulObject : MyClass = null) : void
{
    //Do some stuff

    if (usefulObject)
        doOtherStuff(usefulObject);
}
&lt;/pre&gt;

&lt;p&gt;As it is, this will work fine. You have a &lt;em&gt;howMany&lt;/em&gt; argument, and an optional &lt;em&gt;usefulObject&lt;/em&gt; argument.&lt;/p&gt; 

&lt;p&gt;Everything is going fine, and one day you decide that you can actually use the &lt;em&gt;doStuff()&lt;/em&gt; function on all sorts of different objects, as well as instances of &lt;em&gt;MyClass&lt;/em&gt; - but you'd like to keep the semantics of it the same, so the parameter is still optional.&lt;/p&gt; 

&lt;p&gt;You've just introduced a bug. One that you won't trip up any existing unit tests, too.&lt;/p&gt;

&lt;p&gt;If you're lucky you'll find it soon, but probably not. If it's a week or two before you need to pass in an empty string, or the number 0, or &lt;em&gt;false&lt;/em&gt;, you'll be left scratching your head wondering why it's not doing what it's supposed to.&lt;/p&gt;

&lt;p&gt;This is why I think it's not necessarily a good practice to be recommending to ActionScript beginners.&lt;/p&gt;

&lt;p&gt;I still do it, but I'm trying to weed it out. Once I break the habit, it'll definitely cut down on the syntax errors I put in my Java, anyway ;-)&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/2663078107911472059/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=2663078107911472059" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/2663078107911472059?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/2663078107911472059?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2009/03/on-using-iffoo-vs-iffoo-null.html" title="On using &quot;if(foo)&quot; vs &quot;if(foo != null)&quot;" /><author><name>Josh McDonald</name><uri>http://www.blogger.com/profile/16442649328289782363</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/_ht3yWCqt7ac/ShNYmrF7MVI/AAAAAAAAAB0/akAX--H-xEs/S220/Photo+9.jpg" /></author><thr:total>3</thr:total></entry><entry gd:etag="W/&quot;D0MARX4-cCp7ImA9WxVWEE8.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-2585724747259573179</id><published>2009-02-19T16:28:00.003+10:00</published><updated>2009-02-19T16:37:24.058+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-19T16:37:24.058+10:00</app:edited><title>Using "protected" as a namespace</title><content type="html">&lt;p&gt;I'm a big fan of certain aspects of Object-Oriented software development, one being &lt;a href="http://en.wikipedia.org/wiki/Information_hiding" title="Information hiding - Wikipedia, the free encyclopedia"&gt;information hiding&lt;/a&gt;. Not in a way that makes it hard to extend classes, but in order to keep the public API as small and neat as possible. That means favouring &lt;em&gt;protected&lt;/em&gt; over &lt;em&gt;private&lt;/em&gt;, but often I want a read-only or write-only property in the public API, while still supporting binding (or any other processing on set). This can be a problem at compile time when you'd like to be able to use both internally, however. Take the following code snippet of real code:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;//----------------------------------
// selectedUser
//----------------------------------

private var _selectedUser : User;

[Bindable(&amp;quot;selectedUserChanged&amp;quot;)]
public function get selectedUser() : User
{
    return _selectedUser;
}

protected function set selectedUser(value : User) : void
{
    if (_selectedUser == value)
        return;

    _selectedUser = value;
    dispatchEvent(new Event(&amp;quot;selectedUserChanged&amp;quot;));
}

//----------------------------------
// Selection callback
//----------------------------------

public function selected(item : Object) : void
{
    if (item == null || displayUsers.contains(item))
        selectedUser = User(item);
}&lt;/pre&gt;

&lt;p&gt;MXMLC will give us "Error 1000: Ambiguous reference to selectedUser" when we try to compile this code. &lt;a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Namespace.html" title="Namespace (ActionScript 3.0)"&gt;Namespaces&lt;/a&gt; to the rescue! Did you know you can use &lt;em&gt;public&lt;/em&gt;, &lt;em&gt;package&lt;/em&gt;, &lt;em&gt;protected&lt;/em&gt; and &lt;em&gt;private&lt;/em&gt; just as you would a normal namespace in most cases? The solution to this particular problem then becomes:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;public function selected(item : Object) : void
{
    if (item == null || displayUsers.contains(item))
        protected::selectedUser = User(item);
}&lt;/pre&gt;

&lt;p&gt;You may note that instead of a protected accessor, I could have cooked up a protected &lt;em&gt;setSelectedUser()&lt;/em&gt; function. Which is true, but using the namespace prefix allows me to retain the assignment operator, which I find clearer.&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/2585724747259573179/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=2585724747259573179" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/2585724747259573179?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/2585724747259573179?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2009/02/using-protected-as-namespace.html" title="Using &quot;protected&quot; as a namespace" /><author><name>Josh McDonald</name><uri>http://www.blogger.com/profile/16442649328289782363</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/_ht3yWCqt7ac/ShNYmrF7MVI/AAAAAAAAAB0/akAX--H-xEs/S220/Photo+9.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkMHQXkzeip7ImA9WxVXFEU.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-5013327290726433491</id><published>2009-02-13T11:26:00.001+10:00</published><updated>2009-02-13T11:27:10.782+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-13T11:27:10.782+10:00</app:edited><title>A small request...</title><content type="html">&lt;p&gt;I have a small request:&lt;/p&gt;

&lt;p&gt;I'd like to know what grinds your gears, and what makes you smile about the Flex library, and about whatever other libraries you use on a daily basis to get your work done. If you have time, please post here or to me off-list a quick summary of your thoughts, some bullet points, or even a link to somebody else's blog posting that sums up your ideas. Anything you've got to say, even if it's no more than "PureMVC ftw!", I'd like to hear it.&lt;/p&gt;

&lt;p&gt;I have a keen interest in frameworks, and I'm planning on building something that takes the best ideas I can find (and cook up) from these and my experiences maintaining a mostly-closed-source framework at my 9-5. It's for my own apps, I'll be dog-fooding it, but it will be open source. It's going to be a full-stack framework with an optional Java+Warp+BlazeDS component, so if you think you've got some good ideas, or would like to help, please drop me a line.&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/5013327290726433491/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=5013327290726433491" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/5013327290726433491?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/5013327290726433491?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2009/02/small-request.html" title="A small request..." /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>8</thr:total></entry><entry gd:etag="W/&quot;DUQGR3Y-fip7ImA9WxVRF00.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-853748996901158522</id><published>2009-01-23T20:29:00.002+10:00</published><updated>2009-01-23T20:42:06.856+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-23T20:42:06.856+10:00</app:edited><title>Excuses - er, I mean, an announcement!</title><content type="html">&lt;p&gt;No code this week! But I &lt;i&gt;have&lt;/i&gt; been doing some hacking - I'm very happy to say that I've joined the &lt;a href="http://www.degrafa.org/"&gt;Degrafa&lt;/a&gt; team, and I'm hard at work on some new features, starting with bindable filters. What's that mean? Well the short of it is that you'll be able to bind filter parameters to data in MXML, and Degrafa will know about the updates and re-render when appropriate. No more: &lt;code&gt;"var tmp:Array = foo.filters; foo.filters=null; foo.filters = tmp;"&lt;/code&gt;. I don't know about you guys, but I'm *sick* of doing that :)&lt;/p&gt;

&lt;p&gt;It's not much, and the changes aren't ready to go upstream into SVN yet so you can't use the features, but you can see an example of what I'm talking about &lt;a href="http://www.gfunk007.com/folio/degrafaTest/DegrafaTestBed.html"&gt;here&lt;/a&gt;. For some reason it's much smoother on Mac than Windows (at least with Player 9), but it's just a work-in-progress.&lt;/p&gt;

&lt;p&gt;It's not final, but I'm &lt;i&gt;trying&lt;/i&gt; to find a nice way to let you use the Degrafa bindable filters on regular DisplayObjects. No promises, but I'm trying!&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/853748996901158522/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=853748996901158522" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/853748996901158522?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/853748996901158522?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2009/01/excuses-er-i-mean-announcement.html" title="Excuses - er, I mean, an announcement!" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DUUARX09fSp7ImA9WxVSGUU.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-7031222781263779346</id><published>2009-01-15T12:37:00.001+10:00</published><updated>2009-01-15T12:40:44.365+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-15T12:40:44.365+10:00</app:edited><title>Painless CSS support for Flex components</title><content type="html">&lt;p&gt;As I'm sure you can tell, I've been doing a lot with &lt;a href="http://degrafa.org/" title="Degrafa : Declarative Graphics Framework"&gt;Degrafa&lt;/a&gt; and custom components recently. One thing I've found frustrating while doing so is supporting styles, both custom and built-in. To combat this, I've cooked up a little something I call the &lt;a href="http://code.google.com/p/barra/source/browse/trunk/src/info/joshmcdonald/barra/utils/StyleProxy.as" title="barra - Google Code"&gt;StyleProxy&lt;/a&gt;.

&lt;p&gt;Usage is simple. First, you'll need an instance of StyleProxy for your component:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
&amp;lt;utils:StyleProxy id=&amp;quot;styleProxy&amp;quot;/&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Second, make sure you have a &lt;em&gt;&amp;lt;mx:Script&amp;gt;&lt;/em&gt; section in your MXML file and add this function:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
override public function styleChanged(styleProp : String) : void
{
    super.styleChanged(styleProp);
    styleProxy.handleStyleChange(styleProp);
}
&lt;/pre&gt;                
            
&lt;p&gt;And you're done! Now, all you need to do is bind to properties on &lt;em&gt;styleProxy&lt;/em&gt; using the style name. StyleProxy will take care of the rest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bonus&lt;/strong&gt;: I've uploaded the source code for a simple button skin combining &lt;a href="http://degrafa.org/" title="Degrafa : Declarative Graphics Framework"&gt;Degrafa&lt;/a&gt; and StyleProxy: &lt;a href="http://pastie.textmate.org/361120" title="#361120 by Josh (josh) - Pastie"&gt;View the example code&lt;/a&gt;.

&lt;p&gt;StyleProxy is available for &lt;a href="http://code.google.com/p/barra/" title="barra - Google Code"&gt;download from Google Code&lt;/a&gt;.&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/7031222781263779346/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=7031222781263779346" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/7031222781263779346?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/7031222781263779346?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2009/01/painless-css-support-for-flex.html" title="Painless CSS support for Flex components" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;CEEHR3k7cSp7ImA9WxVTGUg.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-2022136136673502576</id><published>2009-01-03T13:14:00.001+10:00</published><updated>2009-01-03T13:17:16.709+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-03T13:17:16.709+10:00</app:edited><title>More Degrafa madness - Scrollbars and Illustrator</title><content type="html">&lt;p&gt;The holidays are almost over! I've been doing some bludging, some swimming, spent some time at the beach, watched some cricket, ate (too much) pudding and brandy sauce, and finally finished my damned scrollbars to a satisfactory level. To jump right in and see the final product, click the image below:&lt;/p&gt;

&lt;div align="center"&gt;
    &lt;a href="http://www.gfunk007.com/flexandthecity/Scrollbar/Scrollbar.html"&gt;&lt;img src="http://www.gfunk007.com/flexandthecity/images/scrollbars.gif" border="0"&gt;&lt;/a&gt;
    &lt;br/&gt;
    &lt;a href="http://www.gfunk007.com/flexandthecity/Scrollbar/Scrollbar.html"&gt;Click to view (view-source enabled)&lt;/a&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;NB&lt;/strong&gt;: This works with &lt;a href="http://degrafa.googlecode.com/svn/branches/Origin/Degrafa"&gt;Degrafa SVN&lt;/a&gt;, I haven't tested it against the pre-compiled .swf.&lt;/p&gt;

&lt;p&gt;You'll find included in the package the &lt;a href="http://www.gfunk007.com/flexandthecity/Scrollbar/srcview/source/artwork.ai"&gt;Adobe Illustrator File&lt;/a&gt; I created for the artwork, as well as the individual SVG files for the resources.&lt;/p&gt;

&lt;p&gt;A few things to note:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;I had to copy-and-paste each element of the scrollbar into a temporary new document in Illustrator before exporting as SVG, just to keep things simple.&lt;/li&gt;
    &lt;li&gt;The gradients and path data have been a little hand-tweaked for positioning.&lt;/li&gt;
    &lt;li&gt;Illustrator will use commas for all whitespace when exporting path data, but will default to no whitespace at all when it's not needed (negative numbers for example don't need whitespace to separate them from their predecessors). This is valid SVG (and Degrafa path data), but I just prefer to separate coordinate pairs with spaces, and x/y values with commas.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As always, your feedback is appreciated! Please let me know if you've got any questions, corrections, or suggestions!&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/2022136136673502576/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=2022136136673502576" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/2022136136673502576?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/2022136136673502576?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2009/01/more-degrafa-madness-scrollbars-and.html" title="More Degrafa madness - Scrollbars and Illustrator" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;CkUNQnkyeCp7ImA9WxRaFks.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-3488718035721685835</id><published>2008-12-19T14:16:00.003+10:00</published><updated>2008-12-19T14:18:13.790+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-19T14:18:13.790+10:00</app:edited><title>Happy holidays!</title><content type="html">&lt;p&gt;Happy Holidays, all! Going offline for a week or so, but I've got big plans for the new year! Hopefully I'll get connected once or twice and publish a half-done post or two I've got lying around, but there's an &lt;i&gt;awful&lt;/i&gt; lot of drinking, fishing, swimming, barbecuing, and cricket-watching to be done.&lt;/p&gt;

&lt;p&gt;Have a happy and safe break guys :)&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/3488718035721685835/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=3488718035721685835" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/3488718035721685835?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/3488718035721685835?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/12/happy-holidays.html" title="Happy holidays!" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;Ak4AQX47eSp7ImA9WxRbE0g.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-1459021484098158309</id><published>2008-12-04T12:41:00.001+10:00</published><updated>2008-12-04T12:49:00.001+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-04T12:49:00.001+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tools" /><category scheme="http://www.blogger.com/atom/ns#" term="design" /><category scheme="http://www.blogger.com/atom/ns#" term="workflow" /><title>A useful tool</title><content type="html">&lt;p&gt;I'd like to take a moment to recommend &lt;a href="http://www.iconico.com/caliper/" title="Screen Calipers, The Unique On-Screen Measurement Tool"&gt;Screen Calipers&lt;/a&gt;. I'm a perfectionist when I'm working on custom interfaces, components and skins, so I use it all the time. It helps me check padding values, sizing, spacing, border widths, you name it. It's definitely worth the US$30.&lt;/p&gt;

&lt;p&gt;What do you use to get things done, besides builder? I'm always looking for ways to improve my productivity and cut down on the boring parts of my day!&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/1459021484098158309/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=1459021484098158309" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/1459021484098158309?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/1459021484098158309?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/12/useful-tool.html" title="A useful tool" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUIDRng9fyp7ImA9WxRUFk8.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-4174407221877189857</id><published>2008-11-26T00:30:00.001+10:00</published><updated>2008-11-26T00:32:57.667+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-11-26T00:32:57.667+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Dependency Injection" /><category scheme="http://www.blogger.com/atom/ns#" term="Smartypants" /><category scheme="http://www.blogger.com/atom/ns#" term="IOC" /><category scheme="http://www.blogger.com/atom/ns#" term="Frameworks" /><title>A slightly more thorough introduction to Smartypants-IOC</title><content type="html">&lt;p&gt;I'm writing up some info on &lt;a href="http://code.google.com/p/smartypants-ioc/" title="smartypants-ioc - Google Code"&gt;Smartypants-IOC&lt;/a&gt; which will hopefully make it into &lt;a href="http://twitter.com/dhanji" title="Twitter / dhanji"&gt;@dhanji&lt;/a&gt;'s upcoming &lt;a href="http://manning.com/prasanna/" title="Manning: Dependency Injection"&gt;book on Dependency Injection&lt;/a&gt;, so I figured I'd kill two birds with one stone, and finally update my damned blog while I'm at it. &lt;/p&gt;

&lt;p&gt;First I'll introduce a couple of key concepts:&lt;/p&gt;

&lt;h3&gt;The class+name key&lt;/h3&gt;

&lt;p&gt;Whether you're telling Smartypants what to provide, or sitting around with your hand out asking for a dependency, the key is the same. A combination of a &lt;strong&gt;class&lt;/strong&gt; and a &lt;strong&gt;name&lt;/strong&gt;. You need to specify the class, but the name is optional.&lt;/p&gt;

&lt;h3&gt;Injection annotations&lt;/h3&gt;

&lt;p&gt;How do you actually request a field be injected, you ask? In most circumstances you just need to annotate your fields with some ActionScript metadata. If you just want to request an instance of IServiceInterface, the syntax is simple:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
[Inject]
public var myService : IServiceInterface;
&lt;/pre&gt;

&lt;p&gt;As I mentioned above, the injector works using a compound key of both &lt;strong&gt;Class&lt;/strong&gt; and &lt;strong&gt;Name&lt;/strong&gt;. Let's say you want to look up a &lt;em&gt;particular&lt;/em&gt; String, rather than just anything. For a WSDL URL, or something along those lines:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
[Inject(name="mainWSDL")]
public var myServiceWSDL : String;
&lt;/pre&gt;

&lt;p&gt;These fields will be injected into your object when it is constructed for you by Smartypants-IOC, or when you call &lt;strong&gt;injector.injectInto(myInstance)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We also have &lt;em&gt;live injections&lt;/em&gt;, which when coupled with &lt;em&gt;live rules&lt;/em&gt; behave like the Flex SDK's data binding functionality:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
//This will be set whenever the source changes
[Inject(name="userName",live)]
public var currentUsername : String;
&lt;/pre&gt;

&lt;h3&gt;Injector Rules&lt;/h3&gt;

&lt;p&gt;Smartypants injector rules are akin to Guice's &lt;em&gt;bindings&lt;/em&gt;. We simply use another term to avoid confusion with the Flex SDK's data-binding mechanism. You just tell the injector what you'd like it to do. Here's a couple of examples:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
//Simple singleton rules:
injector.newRule().whenAskedFor(String).named("wsdl").useInstance("http://www.server.com/soap/service.wsdl");
injector.newRule().whenAskedFor(IServiceInterface).useSingletonOf(MyServiceImpl);
injector.newRule().whenAskedFor(MyConcreteClass).useSingleton();

//"Live" rules act just like &amp;lt;mx:Binding&amp;gt;
injector.newRule().whenAskedFor(String).named("userId").useBindableProperty(this, "userId");
&lt;/pre&gt;

&lt;h3&gt;But how do I kickstart the whole thing?&lt;/h3&gt;

&lt;p&gt;Good question! Two ways. First, in an MXML component:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;
&amp;lt;mx:Canvas xmlns:mx=&amp;quot;http://www.adobe.com/2006/mxml&amp;quot; xmlns:smartypants=&amp;quot;http://net.expantra.smartypants/2008&amp;quot;&amp;gt;

    &amp;lt;smartypants:RequestInjection/&amp;gt;

    &amp;lt;!-- ...Regular code and MXML... --&amp;gt;

&amp;lt;/mx:Canvas&amp;gt;
&lt;/pre&gt;

&lt;p&gt;And in ActionScript it's even simpler:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
var injector : Injector = Smartypants.getOrCreateInjectorFor(this);
injector.injectInto(this);
&lt;/pre&gt;

&lt;p&gt;Hopefully this gives a little more insight into the style and ideas behind Smartypants-IOC. Be sure to check it out on &lt;a href="http://code.google.com/p/smartypants-ioc/" title="smartypants-ioc - Google Code"&gt;the Google Code site&lt;/a&gt;, and I'd love to hear your thoughts and ideas for the future!&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/4174407221877189857/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=4174407221877189857" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/4174407221877189857?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/4174407221877189857?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/11/slightly-more-thorough-introduction-to.html" title="A slightly more thorough introduction to Smartypants-IOC" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>5</thr:total></entry><entry gd:etag="W/&quot;C0MERXc8eyp7ImA9WxRVEEw.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-6997175039829338941</id><published>2008-11-07T08:37:00.002+10:00</published><updated>2008-11-07T08:43:24.973+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-11-07T08:43:24.973+10:00</app:edited><title>DSLs in MXML</title><content type="html">I like DSLs, and god-help me I like MXML. Mainly for the auto-complete features we get from Builder. I've recently built a new application framework at &lt;a href="http://intelligentpathways.com.au/"&gt;Pathways&lt;/a&gt; (my 9-5), which uses an MXML file as the core of the application to map events, services, actions(think commands), etc. This has got me thinking I'd like to have a tool that'll let me define an MXML DSL and have it spit out a bunch of AS3 classes to implement it. I'd like to hear from anybody who's got any thoughts on the idea, or things they'd like to see included. I probably won't get started on it just yet, but it's floating around in my head with the rest of the crazy ideas waiting to escape into code.</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/6997175039829338941/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=6997175039829338941" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/6997175039829338941?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/6997175039829338941?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/11/dsls-in-mxml.html" title="DSLs in MXML" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C0IHQXw4eSp7ImA9WxRWGUs.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-4295789941420914585</id><published>2008-11-06T18:51:00.000+10:00</published><updated>2008-11-06T18:52:10.231+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-11-06T18:52:10.231+10:00</app:edited><title>Free Book! Giggity!</title><content type="html">&lt;p&gt;I forgot to brag! About a week or so ago, I received my free copy of &lt;a href="http://oreilly.com/catalog/9780596529857/" title="Flex 3 Cookbook | O'Reilly Media"&gt;Flex 3 Cookbook&lt;/a&gt; in the mail, courtesy of the Flex team @ Adobe! An unnecessary but welcome reward for getting 3 SDK patches accepted!&lt;/p&gt;

&lt;div align="center"&gt;
    &lt;img src="http://flexandthecity.gfunk007.com/content/cookbook.jpg" alt="Cookbook!"/&gt;
&lt;/div&gt;

&lt;p&gt;Anyway, enough bragging, and a big thanks to Matt and the rest of the Flex team for building the badass platform we use every day!&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/4295789941420914585/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=4295789941420914585" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/4295789941420914585?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/4295789941420914585?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/11/free-book-giggity.html" title="Free Book! Giggity!" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEEBRnsyfyp7ImA9WxRWGEk.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-16798198423498765</id><published>2008-11-05T09:50:00.001+10:00</published><updated>2008-11-05T09:50:57.597+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-11-05T09:50:57.597+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="flex" /><category scheme="http://www.blogger.com/atom/ns#" term="degrafa" /><category scheme="http://www.blogger.com/atom/ns#" term="skinning" /><title>Skinning Flex apps with Degrafa</title><content type="html">&lt;p&gt;I've been a lazy bastich, but here's the promised post on skinning with &lt;a href="http://www.degrafa.com/" title="Degrafa"&gt;Degrafa&lt;/a&gt;. &lt;strong&gt;Note:&lt;/strong&gt; this is based on Degrafa Beta 2. Beta 3 is expected rather soon, and there'll be a couple of changes such as the new namespace etc.&lt;/p&gt;

&lt;p&gt;OK, for this example, we're going to skin a simple little &amp;lt;mx:Box&amp;gt; to dress it up some. Here's our MXML for the component we'd like to skin:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
&amp;lt;mx:Canvas styleName=&amp;quot;skinnedBox&amp;quot; width=&amp;quot;250&amp;quot; horizontalCenter=&amp;quot;0&amp;quot; verticalCenter=&amp;quot;0&amp;quot;&amp;gt;
    &amp;lt;mx:Text width=&amp;quot;100%&amp;quot;&amp;gt;
        &amp;lt;mx:text&amp;gt;
            Aliquam et nisl vel ligula consectetuer suscipit. Morbi euismod enim eget neque. Donec sagittis
            massa. Vestibulum quis augue sit amet ipsum laoreet pretium. Nulla facilisi. Duis tincidunt,
            felis et luctus placerat, ipsum libero vestibulum sem, vitae elementum wisi ipsum a metus.
            Nulla a enim sed dui hendrerit lobortis. Donec lacinia vulputate magna. Vivamus suscipit lectus
            consectetuer adipiscing elit.
        &amp;lt;/mx:text&amp;gt;
    &amp;lt;/mx:Text&amp;gt;
&amp;lt;/mx:Canvas&amp;gt;
&lt;/pre&gt;

&lt;p&gt;And a simple "before" CSS:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
/* CSS file */
.skinnedBox
{
    border-style:solid;
    border-thickness:1;
    border-color:black;
    background-color:#cccccc;
}
&lt;/pre&gt;

&lt;p&gt;Giving us this:&lt;/p&gt;

&lt;div align="center"&gt;
&lt;img src="http://flexandthecity.gfunk007.com/content/sid_before.png" border="0"/&gt;
&lt;/div&gt;

&lt;p&gt;And we're going to skin it so it looks like this:&lt;/p&gt;

&lt;div align="center"&gt;
&lt;img src="http://flexandthecity.gfunk007.com/content/sid_after.png" border="0"/&gt;
&lt;/div&gt;

&lt;p&gt;If we were skinning a Button, we'd use things like &lt;em&gt;up-skin&lt;/em&gt;, &lt;em&gt;down-skin&lt;/em&gt;, etc. But, we're just skinning a box, so we'll use border-skin:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
/* CSS file */
.skinnedBox
{
    border-skin:ClassReference("skinningInDegrafa.ShinySkin");
}
&lt;/pre&gt;

&lt;p&gt;We want to specify the borderMetrics of our skin (to add the padding), so we'll subclass &amp;lt;degrafa:GraphicRectangularBorderSkin&amp;gt;:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;
&amp;lt;degrafa:GraphicRectangularBorderSkin xmlns:mx=&amp;quot;http://www.adobe.com/2006/mxml&amp;quot; width=&amp;quot;400&amp;quot; height=&amp;quot;300&amp;quot; xmlns:degrafa=&amp;quot;http://www.degrafa.com/2007&amp;quot;&amp;gt;

    &amp;lt;mx:Script&amp;gt;
        &amp;lt;![CDATA[
            import mx.core.EdgeMetrics;
&lt;/pre&gt;

&lt;p&gt;We need to keep a copy of the width and height which is set by the framework. The actual height and width are set on &lt;em&gt;updateDisplayList&lt;/em&gt;, which is as good a place as any to take note of them, and we'll have less unnecessary updates that way:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
            [Bindable]
            private var skinWidth : Number = 0;

            [Bindable]
            private var skinHeight : Number = 0;

            private var edges : EdgeMetrics = new EdgeMetrics(20, 5, 20, 5);

            override protected function updateDisplayList(unscaledWidth : Number, unscaledHeight : Number) : void
            {
                skinWidth = unscaledWidth;
                skinHeight = unscaledHeight;
                super.updateDisplayList(unscaledWidth, unscaledHeight);
            }

            override public function get borderMetrics() : EdgeMetrics
            {
                return edges;
            }

        ]]&amp;gt;
    &amp;lt;/mx:Script&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Below is the exciting part that defines the shapes and fills! A how-to on Degrafa in general is out of scope for this post, so see the &lt;a href="http://www.degrafa.com/" title="Degrafa"&gt;Degrafa site&lt;/a&gt; for &lt;a href="http://docs.degrafa.com/" title="Degrafa Docs"&gt;documentation&lt;/a&gt; and more &lt;a href="http://samples.degrafa.com/" title="Degrafa samples"&gt;examples&lt;/a&gt;.&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
    &amp;lt;degrafa:fills&amp;gt;
        &amp;lt;degrafa:LinearGradientFill angle=&amp;quot;90&amp;quot; id=&amp;quot;f&amp;quot;&amp;gt;
            &amp;lt;degrafa:GradientStop ratio=&amp;quot;0&amp;quot; color=&amp;quot;#dde4ee&amp;quot;/&amp;gt;
            &amp;lt;degrafa:GradientStop ratio=&amp;quot;1&amp;quot; color=&amp;quot;#aaa0bb&amp;quot;/&amp;gt;
        &amp;lt;/degrafa:LinearGradientFill&amp;gt;

        &amp;lt;degrafa:LinearGradientFill angle=&amp;quot;90&amp;quot; id=&amp;quot;f2&amp;quot;&amp;gt;
            &amp;lt;degrafa:GradientStop ratio=&amp;quot;0.3&amp;quot; alpha=&amp;quot;0.02&amp;quot; color=&amp;quot;#ffffff&amp;quot;/&amp;gt;
            &amp;lt;degrafa:GradientStop ratio=&amp;quot;1&amp;quot; alpha=&amp;quot;0.3&amp;quot; color=&amp;quot;#ffffff&amp;quot;/&amp;gt;
        &amp;lt;/degrafa:LinearGradientFill&amp;gt;
    &amp;lt;/degrafa:fills&amp;gt;

    &amp;lt;degrafa:geometry&amp;gt;

        &amp;lt;degrafa:Path fill=&amp;quot;{f}&amp;quot;&amp;gt;
            &amp;lt;degrafa:MoveTo x=&amp;quot;0&amp;quot; y=&amp;quot;{ skinHeight / 2 }&amp;quot;/&amp;gt;
            &amp;lt;degrafa:CubicBezierTo x=&amp;quot;20&amp;quot; y=&amp;quot;0&amp;quot; cx=&amp;quot;0&amp;quot; cy=&amp;quot;{skinHeight * 0.25}&amp;quot; cx1=&amp;quot;1&amp;quot; cy1=&amp;quot;1&amp;quot;/&amp;gt;
            &amp;lt;degrafa:LineTo x=&amp;quot;{ skinWidth - 20}&amp;quot; y=&amp;quot;0&amp;quot;/&amp;gt;
            &amp;lt;degrafa:CubicBezierTo x=&amp;quot;{ skinWidth }&amp;quot; y=&amp;quot;{ skinHeight / 2 }&amp;quot; cx=&amp;quot;{ skinWidth - 1}&amp;quot; cy=&amp;quot;1&amp;quot; cx1=&amp;quot;{ skinWidth }&amp;quot; cy1=&amp;quot;{ skinHeight * 0.25 }&amp;quot;/&amp;gt;
            &amp;lt;degrafa:CubicBezierTo x=&amp;quot;{ skinWidth - 20 }&amp;quot; y=&amp;quot;{ skinHeight }&amp;quot; cx=&amp;quot;{ skinWidth }&amp;quot; cy=&amp;quot;{ skinHeight * 0.75 }&amp;quot; cx1=&amp;quot;{ skinWidth - 1 }&amp;quot; cy1=&amp;quot;{ skinHeight - 1 }&amp;quot;/&amp;gt;
            &amp;lt;degrafa:LineTo x=&amp;quot;20&amp;quot; y=&amp;quot;{ skinHeight }&amp;quot;/&amp;gt;
            &amp;lt;degrafa:CubicBezierTo x=&amp;quot;0&amp;quot; y=&amp;quot;{ skinHeight / 2 }&amp;quot; cx=&amp;quot;1&amp;quot; cy=&amp;quot;{ skinHeight - 1 }&amp;quot; cx1=&amp;quot;0&amp;quot; cy1=&amp;quot;{ skinHeight * 0.75 }&amp;quot;/&amp;gt;
            &amp;lt;degrafa:ClosePath/&amp;gt;
        &amp;lt;/degrafa:Path&amp;gt;

        &amp;lt;degrafa:Path fill=&amp;quot;{f2}&amp;quot;&amp;gt;
            &amp;lt;degrafa:MoveTo x=&amp;quot;10&amp;quot; y=&amp;quot;{ skinHeight / 2 }&amp;quot;/&amp;gt;
            &amp;lt;degrafa:CubicBezierTo x=&amp;quot;20&amp;quot; y=&amp;quot;0&amp;quot; cx=&amp;quot;0&amp;quot; cy=&amp;quot;{skinHeight * 0.25}&amp;quot; cx1=&amp;quot;1&amp;quot; cy1=&amp;quot;1&amp;quot;/&amp;gt;
            &amp;lt;degrafa:LineTo x=&amp;quot;{ skinWidth - 20}&amp;quot; y=&amp;quot;0&amp;quot;/&amp;gt;
            &amp;lt;degrafa:CubicBezierTo x=&amp;quot;{ skinWidth - 10 }&amp;quot; y=&amp;quot;{ skinHeight / 2 }&amp;quot; cx=&amp;quot;{ skinWidth - 1}&amp;quot; cy=&amp;quot;1&amp;quot; cx1=&amp;quot;{ skinWidth }&amp;quot; cy1=&amp;quot;{ skinHeight * 0.25 }&amp;quot;/&amp;gt;
            &amp;lt;degrafa:CubicBezierTo x=&amp;quot;10&amp;quot; y=&amp;quot;{ skinHeight / 2 }&amp;quot; cx=&amp;quot;{ skinWidth * 0.75 }&amp;quot; cy=&amp;quot;{ skinHeight * 0.4}&amp;quot; cx1=&amp;quot;{ skinWidth * 0.25 }&amp;quot; cy1=&amp;quot;{ skinHeight * 0.4}&amp;quot;/&amp;gt;
            &amp;lt;degrafa:ClosePath/&amp;gt;
        &amp;lt;/degrafa:Path&amp;gt;

    &amp;lt;/degrafa:geometry&amp;gt;

    &amp;lt;degrafa:filters&amp;gt;
        &amp;lt;mx:GlowFilter inner=&amp;quot;true&amp;quot; color=&amp;quot;#000000&amp;quot; blurX=&amp;quot;3&amp;quot; blurY=&amp;quot;3&amp;quot; alpha=&amp;quot;0.3&amp;quot;/&amp;gt;
        &amp;lt;mx:DropShadowFilter alpha=&amp;quot;0.3&amp;quot; angle=&amp;quot;90&amp;quot; distance=&amp;quot;5&amp;quot; blurX=&amp;quot;8&amp;quot; blurY=&amp;quot;8&amp;quot;/&amp;gt;
    &amp;lt;/degrafa:filters&amp;gt;

&amp;lt;/degrafa:GraphicRectangularBorderSkin&amp;gt;
&lt;/pre&gt;

&lt;p&gt;And that's a pretty simple example of skinning with Degrafa! Here's the &lt;a href="http://www.gfunk007.com/flexandthecity/content/bin-release/BlogPosts.html" title=""&gt;complete example (with view-source enabled)&lt;/a&gt;.&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/16798198423498765/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=16798198423498765" title="7 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/16798198423498765?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/16798198423498765?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/11/skinning-flex-apps-with-degrafa.html" title="Skinning Flex apps with Degrafa" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>7</thr:total></entry><entry gd:etag="W/&quot;DkYDRXk6cSp7ImA9WxVUEkU.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-4262439137130788354</id><published>2008-10-16T21:12:00.002+10:00</published><updated>2009-03-17T20:02:54.719+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-17T20:02:54.719+10:00</app:edited><title>Selecting the right value from a ComboBox or List</title><content type="html">&lt;p&gt;I know, I promised Degrafa skinning, and I'm skipping out. It'll be next, if I can find the time!&lt;/p&gt;

&lt;p&gt;
    In other news, there's been &lt;a href="http://tech.groups.yahoo.com/group/flexcoders/message/127357" title="Yahoo! Groups"&gt;some talk&lt;/a&gt; as there always is
    regarding the difficulty some have been having due to the fact ComboBox (and others like it) work with identity rather than contents when choosing which 
    item within the dataProvider is the "selected" value. There are various solutions, usually involving 
    &lt;a href="http://www.forta.com/blog/index.cfm/2006/11/22/Flex-ComboBox-With-selectedValue-Support" title="Forta.com - Blog"&gt;subclassing ComboBox&lt;/a&gt;
    or something along those lines. Well, that's kinda unnecessary. I maintained that you could cook up a util to achieve the same thing across any
    list-style control, and by golly I like to stand up to my word.
&lt;/p&gt;

&lt;p&gt;
    You can download the source for the util &lt;a href="http://barra.googlecode.com/svn/trunk/src/info/joshmcdonald/barra/utils/FindIndex.as" title="Code snippet - FindIndex.as"&gt;here&lt;/a&gt;. I'll add it to 
    SVN soon, I'm kinda busy atm tho. Lousy sleep eating up 8 hours of productivity a day!
&lt;/p&gt;

&lt;p&gt;For an example of how to use the &lt;em&gt;&amp;lt;FindIndex&amp;gt;&lt;/em&gt; code:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;
&amp;lt;mx:Application xmlns:mx=&amp;quot;http://www.adobe.com/2006/mxml&amp;quot; layout=&amp;quot;absolute&amp;quot; xmlns:pkg=&amp;quot;pkg.*&amp;quot;&amp;gt;

    &amp;lt;mx:ArrayCollection id=&amp;quot;src1&amp;quot;&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Ken&amp;quot; objid=&amp;quot;1&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Ryu&amp;quot; objid=&amp;quot;2&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Chun-Li&amp;quot; objid=&amp;quot;3&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Dhalsim&amp;quot; objid=&amp;quot;4&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;E. Honda&amp;quot; objid=&amp;quot;5&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Blanka&amp;quot; objid=&amp;quot;6&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Zangief&amp;quot; objid=&amp;quot;7&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Guile&amp;quot; objid=&amp;quot;8&amp;quot;/&amp;gt;
    &amp;lt;/mx:ArrayCollection&amp;gt;

    &amp;lt;mx:ArrayCollection id=&amp;quot;src2&amp;quot;&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Ken&amp;quot; objid=&amp;quot;1&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Ryu&amp;quot; objid=&amp;quot;2&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Chun-Li&amp;quot; objid=&amp;quot;3&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Dhalsim&amp;quot; objid=&amp;quot;4&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;E. Honda&amp;quot; objid=&amp;quot;5&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Blanka&amp;quot; objid=&amp;quot;6&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Zangief&amp;quot; objid=&amp;quot;7&amp;quot;/&amp;gt;
        &amp;lt;mx:Object label=&amp;quot;Guile&amp;quot; objid=&amp;quot;8&amp;quot;/&amp;gt;
    &amp;lt;/mx:ArrayCollection&amp;gt;

    &amp;lt;pkg:FindIndex source=&amp;quot;{src2}&amp;quot; keyField=&amp;quot;objid&amp;quot; searchFor=&amp;quot;{ left.selectedItem }&amp;quot; id=&amp;quot;fi&amp;quot;/&amp;gt;

    &amp;lt;mx:HBox horizontalCenter=&amp;quot;0&amp;quot; verticalCenter=&amp;quot;0&amp;quot;&amp;gt;

        &amp;lt;mx:List id=&amp;quot;left&amp;quot; dataProvider=&amp;quot;{src1}&amp;quot; width=&amp;quot;120&amp;quot;/&amp;gt;

        &amp;lt;mx:List id=&amp;quot;right&amp;quot; dataProvider=&amp;quot;{src2}&amp;quot; selectedIndex=&amp;quot;{ fi.matchingIndex }&amp;quot; width=&amp;quot;120&amp;quot;/&amp;gt;

    &amp;lt;/mx:HBox&amp;gt;
&amp;lt;/mx:Application&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Degrafa skinning &lt;strong&gt;next&lt;/strong&gt; week! &lt;strong&gt;Honest!&lt;/strong&gt;&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/4262439137130788354/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=4262439137130788354" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/4262439137130788354?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/4262439137130788354?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/10/selecting-right-value-from-combobox-or.html" title="Selecting the right value from a ComboBox or List" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>3</thr:total></entry><entry gd:etag="W/&quot;A0cDQn07eyp7ImA9WxJWF08.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-9187643005821026338</id><published>2008-10-09T21:20:00.002+10:00</published><updated>2009-06-23T13:51:13.303+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-23T13:51:13.303+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="barra" /><category scheme="http://www.blogger.com/atom/ns#" term="enums" /><category scheme="http://www.blogger.com/atom/ns#" term="actionscript" /><category scheme="http://www.blogger.com/atom/ns#" term="utils" /><title>Typesafe ActionScript Enums</title><content type="html">&lt;p&gt;A busy week, with some client work and a 4-day weekend away (starting in about 12 hours, woot!), so a quick post.&lt;/p&gt;

&lt;p&gt;
    Typesafe Enums are something we take for granted these days in a lot of programming languages, but unfortunately ActionScript isn't yet
    one of them. However, there are a few solutions out there to provide this functionality, and of course since none of them met
    my needs exatly, this is mine!
&lt;/p&gt;


&lt;p&gt;First, let's jump into how we &lt;em&gt;use&lt;/em&gt; the damn things - here's how you would create a new Enum type:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
package demo
{
    import info.joshmcdonald.barra.utils.Enum;

    public class CompassPoint extends Enum
    {
        public static const NORTH      : CompassPoint = Enum.create(CompassPoint, "N",  "Towards Santa");
        public static const NORTH_EAST : CompassPoint = Enum.create(CompassPoint, "NE", "North East");
        public static const EAST       : CompassPoint = Enum.create(CompassPoint, "E",  "East");
        public static const SOUTH_EAST : CompassPoint = Enum.create(CompassPoint, "SE", "South East");
        public static const SOUTH      : CompassPoint = Enum.create(CompassPoint, "S",  "Towards Penguins");
        public static const SOUTH_WEST : CompassPoint = Enum.create(CompassPoint, "SW", "South West");
        public static const WEST       : CompassPoint = Enum.create(CompassPoint, "W",  "West");
        public static const NORTH_WEST : CompassPoint = Enum.create(CompassPoint, "NW", "North West").close();
    }
}
&lt;/pre&gt;

&lt;p&gt;Seems simple enough, right?&lt;/p&gt;

&lt;p&gt;
    Wait, hold on, &lt;em&gt;"what the hell is that on the end?"&lt;/em&gt; I hear you cry? Why, I'm terribly glad you asked! That my friends, combined with 
    using Enum.create() is how we stop people from instantiating new instances willy-nilly, which of course leads to anarchy! When you call close(), 
    no more instances of Compass can be instantiated, and if you try, you'll get a run-time error.
&lt;/p&gt;

&lt;p&gt;Now, some "client" code that makes use of our new CompassPoint class:&lt;/p&gt;

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:components="info.joshmcdonald.barra.components.*" creationComplete="cc()"&gt;

&lt;pre class="prettyprint"&gt;
&amp;lt;mx:Script&amp;gt;
    &amp;lt;![CDATA[
        import info.joshmcdonald.barra.utils.Enum;
        import demo.CompassPoint;

        private function cc() : void
        {
            var towardsPerth : CompassPoint = CompassPoint.SOUTH_WEST;

            trace(&amp;quot;Direction to Perth is&amp;quot;, towardsPerth);

            trace(&amp;quot;What are all the Compass points?&amp;quot;);
            trace(&amp;quot;   * &amp;quot; + Enum.valuesOf(CompassPoint).join(&amp;quot;\n   * &amp;quot;));
        }

    ]]&amp;gt;
&amp;lt;/mx:Script&amp;gt;
&amp;lt;/mx:Application&amp;gt;
&lt;/pre&gt;

&lt;p&gt;
    As usual, I've added Enum.as to &lt;a href="http://code.google.com/p/barra/" title="barra - Google Code"&gt;my blog's google code repository&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;Next week: Skinning with &lt;a href="http://www.degrafa.com/" title="degrafa"&gt;Degrafa&lt;/a&gt;!&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/9187643005821026338/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=9187643005821026338" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/9187643005821026338?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/9187643005821026338?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/10/typesafe-actionscript-enums.html" title="Typesafe ActionScript Enums" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;D0cMQno6fyp7ImA9WxNRFk4.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-2141684519997666396</id><published>2008-10-02T19:25:00.003+10:00</published><updated>2009-09-11T12:11:23.417+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-11T12:11:23.417+10:00</app:edited><title>Announcing Smartypants IOC,  Dependency Injection for Flex!</title><content type="html">&lt;p&gt;
I'm happy to announce the public release of the &lt;a href="http://code.google.com/p/smartypants-ioc/"&gt;Smartypants IOC&lt;/a&gt; dependency-injection 
framework for Flex! Inspired by the likes of &lt;a href="http://code.google.com/p/google-guice/"&gt;Guice&lt;/a&gt;, it features 
&lt;a href="http://code.google.com/p/smartypants-ioc/wiki/InjectionAnnotations"&gt;annotations&lt;/a&gt; to specify dependencies, and
&lt;a href="http://code.google.com/p/smartypants-ioc/wiki/Rules"&gt;a simple internal DSL&lt;/a&gt; to wire everything together. 
&lt;/p&gt;

&lt;h3&gt;Dependency Injection, Flex style!&lt;/h3&gt;

&lt;p&gt;
    Normally, dependency injection is a static thing. Once your object has been populated and handed over, you and 
    your injection framework are through. However, Smartypants' &lt;b&gt;live injection&lt;/b&gt; functionality acts as a mediator
    allowing bindings between un-coupled classes, without keeping any hard-references to either that can lead to 
    troublesome memory leaks.
&lt;/p&gt;

&lt;p&gt;
    Grab the source or binary over at &lt;a href="http://code.google.com/p/smartypants-ioc/"&gt;Google Code&lt;/a&gt;, check out
    &lt;a href="http://smartypants.expantra.net/asdoc/index.html"&gt;the API reference&lt;/a&gt;, join 
    &lt;a href="http://groups.google.com/group/smartypants-ioc"&gt;the discussion group&lt;/a&gt; and hack away! I'm looking forward to
    your feedback, opinions, and thoughts on the direction in which you'd like to see Smartypants IOC heading in the future?
&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/2141684519997666396/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=2141684519997666396" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/2141684519997666396?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/2141684519997666396?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/10/announcing-smartypants-ioc-dependency.html" title="Announcing Smartypants IOC,  Dependency Injection for Flex!" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;CEINRnY5fCp7ImA9WxRRE0k.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-28140292295620592</id><published>2008-09-25T21:18:00.002+10:00</published><updated>2008-09-25T21:36:37.824+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-25T21:36:37.824+10:00</app:edited><title>Screenweaver - an open source alternative to AIR?</title><content type="html">&lt;p&gt;I don't have a detailed post this week as I've been working on cleaning up and refactoring my IOC project for launch next week (I hope). However here's a few interesting links:
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://haxe.org/doc/intro"&gt;haXe&lt;/a&gt; - A multi-platform language with a fairly pleasant syntax based on ECMAScript. You can write code in haXe and compile to SWF (Flash 6 to Flash 9), ActionScript (this isn't too good, I've run into problems), JavaScript, and PHP. It also compiles to NekoVM...&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://screenweaver.org/doku.php?id=about"&gt;Screenweaver Open Source&lt;/a&gt; - This is a bridge between Flash and NekoVM, for Windows and Mac OS. You can do all your GUI code in ActionScript, or you can do it all in haXe as it compiles to SWF as well as NekoVM.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;
I Haven't played with Screenweaver yet, but I plan on it in the near future! And of course when I do I'll be posting my progress here :)
&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/28140292295620592/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=28140292295620592" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/28140292295620592?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/28140292295620592?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/09/screenweaver-open-source-alternative-to.html" title="Screenweaver - an open source alternative to AIR?" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DEMBRH09fSp7ImA9WxRREEo.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-7662005104893699747</id><published>2008-09-22T19:38:00.003+10:00</published><updated>2008-09-22T19:40:55.365+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-22T19:40:55.365+10:00</app:edited><title>Internet Explorer</title><content type="html">&lt;p&gt;
   &lt;b&gt;Groan&lt;/b&gt;. I think the site's working in IE6 now. Debugging HTML on Explorer (without parallels or a Windows box handy) is pain. This is why I do Flex these days.
&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/7662005104893699747/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=7662005104893699747" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/7662005104893699747?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/7662005104893699747?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/09/internet-explorer.html" title="Internet Explorer" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;A0YFQnY5fSp7ImA9WxJSEUk.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-6036388307247297494</id><published>2008-09-18T21:03:00.002+10:00</published><updated>2009-05-01T13:38:33.825+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-01T13:38:33.825+10:00</app:edited><title>Vertical Scrollbars and 100% width content</title><content type="html">&lt;p&gt;
 I've often wished Flex would simply shrink the available width of my 
 containers when their contents grow too tall, but alas, often you'll find yourself
 with a horizontal scrollbar that only exists to show you the content that's just been
 hidden by the vertical scrollbar that wasn't there a minute ago!
&lt;/p&gt;

&lt;p&gt;
 &lt;a href="http://tech.groups.yahoo.com/group/flexcoders/message/99176"&gt;It's a common question, and the Adobe guys had 
 their reasons for making it how it is&lt;/a&gt;. Not much consolation for the rest of us though! So, a (perhaps not 
 the, but a) solution:
&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
package info.joshmcdonald.barra.components
{
&lt;/pre&gt;

&lt;p&gt;Shameless self-promotion: I've created a &lt;a href="http://code.google.com/p/barra/"&gt;google code project&lt;/a&gt; for code examples and utils from my blog.&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
    import flash.display.DisplayObject;

    import mx.containers.Canvas;
    import mx.core.UIComponent;

    public class SmartVerticalScroll extends Canvas
    {
        override public function addChild(child : DisplayObject) : DisplayObject
        {
            return addChildAt(child, numChildren);
        }

        override public function addChildAt(child : DisplayObject, index : int) : DisplayObject
        {
            if (numChildren &amp;gt; 0)
                throw new Error(&amp;quot;Only one child, stick a canvas or something in here&amp;quot;);

            return super.addChildAt(child, index);
        }
&lt;/pre&gt;

&lt;p&gt;
 Just to keep thing simple, and this example small, we're limiting this to a single child. Not ideal, but we can 
 get away with it by simply using it as a container for a &lt;b&gt;Canvas&lt;/b&gt; or a &lt;b&gt;VBox&lt;/b&gt; or similar.
&lt;/p&gt;
 
&lt;pre class="prettyprint"&gt;
        override protected function updateDisplayList(unscaledWidth : Number, unscaledHeight : Number) : void
        {
            var innerWidth : Number = unscaledWidth - borderMetrics.left - borderMetrics.right;

            super.updateDisplayList(unscaledWidth, unscaledHeight);

            if (numChildren == 1)
            {
                var child : DisplayObject = getChildAt(0);
                var uic : UIComponent = child as UIComponent;

                if (uic)
                {
                    if (verticalScrollBar)
                    {
                        var newWidth : Number = Math.max(Math.min(uic.width + uic.x , innerWidth - verticalScrollBar.width), uic.measuredMinWidth);
                        uic.setActualSize(newWidth, uic.height);
                    }
                }
                else
                {
                    child.x = 0;
                    child.y = 0;
                }
            }
        }
&lt;/pre&gt;

&lt;p&gt;
 Here's where half the magic lies. If we have a vertical scrollbar, we'll shrink our child component to fit within it,
 unless that would violate its minWidth requirement.
&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
        override public function validateDisplayList() : void
        {
            var before : Boolean = verticalScrollBar == null;
            super.validateDisplayList();
            var after : Boolean = verticalScrollBar == null;

            if (after != before)
            {
                //Scrollbar added or removed - repaint and resize inner component
                invalidateDisplayList();
            }
        }
    }
}
&lt;/pre&gt;

&lt;p&gt;
 Here's the other half of the magic. When we determine that Flex's built in layout code has decided to 
 add a vertical scrollbar, we make sure to schedule another call to our updateDisplayList() so we can
 shrink the content down to get out of the way.
&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/6036388307247297494/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=6036388307247297494" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/6036388307247297494?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/6036388307247297494?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/09/vertical-scrollbars-and-100-width.html" title="Vertical Scrollbars and 100% width content" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>6</thr:total></entry><entry gd:etag="W/&quot;Dk8GRnYyeip7ImA9WxRSEU8.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-7888877896991563565</id><published>2008-09-11T16:57:00.005+10:00</published><updated>2008-09-11T19:20:27.892+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-11T19:20:27.892+10:00</app:edited><title>Bindings, Changewatcher, and memory leaks</title><content type="html">&lt;p&gt;I'm building some stuff with a serious potential to leak memory (but it's &lt;b&gt;hella&lt;/b&gt; cool, watch this space). Specifically, dealing with binding to and from objects without keeping hard references to them, which is easier said than done! I've been going through the source code to the binding system, and all bindings eventually come down to &lt;b&gt;ChangeWatcher.watch()&lt;/b&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When you call watch(), you get returned the first of a chain of watchers, one for every host in the chain.&lt;/li&gt;
&lt;li&gt;Every watcher in the chain with a non-null host has a hard-reference from the host object to itself.&lt;/li&gt;
&lt;li&gt;Every watcher has a hard-ref to the handler function.&lt;/li&gt;&lt;/ol&gt;

&lt;p&gt;This of course leads to the fact that if you ever throw away your watcher reference before calling unWatch(), you're stuck with a zombie reference from the root of your chain to your handler function. Which means in turn that the host object is hard-referenced to anything within the handler function's scope. If the root of your chain happens to be Application, or anything else that lives the life of your app, you're almost certainly leaking memory.&lt;/p&gt;

&lt;p&gt;I'd love to be wrong about my conclusions, but I don't think I am. I'll have to create a test some time over the weekend to prove it though, so I can file a bug (and a fix) with Adobe.&lt;/p&gt;

&lt;p&gt;So in conclusion: Be awfully careful what you're putting in the handler function for any hand-created &lt;b&gt;ChangeWatcher&lt;/b&gt;, or using &lt;b&gt;BindingUtils&lt;/b&gt;!&lt;/p&gt;


&lt;p&gt;Note that I don't think it's a problem for MXML bindings: Off the top of my head, if the root host of a binding chain defined in MXML is "A" then the handler function is generated as a member function of "A".&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/7888877896991563565/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=7888877896991563565" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/7888877896991563565?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/7888877896991563565?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/09/bindings-changewatcher-and-memory-leaks.html" title="Bindings, Changewatcher, and memory leaks" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkMARHY5fip7ImA9WxRTFU8.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-3737565678255668197</id><published>2008-09-04T18:51:00.001+10:00</published><updated>2008-09-04T20:34:05.826+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-04T20:34:05.826+10:00</app:edited><title>Using the Proxy class (part 2)</title><content type="html">&lt;p&gt;
 In the &lt;a href="http://flex.joshmcdonald.info/2008/09/using-proxy-class-part-1_04.html"&gt;first part&lt;/a&gt; of this article I 
 demonstrated using the basic Proxy functionality. Now we get to the fun stuff, which we need to support 
 &lt;a href="http://livedocs.adobe.com/flex/3/langref/statements.html#for..in"&gt;for..in&lt;/a&gt; and 
 &lt;a href="http://livedocs.adobe.com/flex/3/langref/statements.html#for_each..in"&gt;for each..in&lt;/a&gt; constructs.
&lt;/p&gt; 

&lt;pre class="prettyprint"&gt;
//Gets the next index. When you return 0, for..in and for each..in will quit.
override flash_proxy function nextNameIndex(index : int) : int
{
    if (index &amp;lt; propertyNames.length)
        return index + 1;

    return 0;
}
&lt;/pre&gt;

&lt;p&gt;Here's where the Flex docs get kinda confusing :) The first thing the VM does when you're iterating your Proxy object with &lt;b&gt;for..in&lt;/b&gt; or &lt;b&gt;for each..in&lt;/b&gt; 
 is call &lt;b&gt;nextNameIndex(0)&lt;/b&gt;. The docs tell you the input is zero-based, but that's not the case, 0 isn't "first", 1 is. So when flex asks for the "next name from zero" 
 it's actually asking if there's a first name at all. If you've got more properties to iterate, return index + 1. Otherwise, return 0 and the loop will end.&lt;/p&gt;

&lt;p&gt;Note that you don't *have* to return index +1. This is how &lt;b&gt;ArrayCollection&lt;/b&gt;, &lt;b&gt;ListCollectionView&lt;/b&gt; and the like implement filters. But that's another post :)&lt;/p&gt;
  
&lt;pre class="prettyprint"&gt;
//Get name[i] where i is 1-based
override flash_proxy function nextName(index : int) : String
{
    return propertyNames[index - 1];
}

//Get value[i] where index is 1-based.
override flash_proxy function nextValue(index : int) : *
{
 return properties[propertyNames[index - 1]];
}
&lt;/pre&gt;

&lt;p&gt;
 These two functions are the other half of the &lt;b&gt;for..in&lt;/b&gt; and &lt;b&gt;for each..in&lt;/b&gt; loops. After the VM gets the next index from &lt;b&gt;nextNameIndex()&lt;/b&gt; it will
 call one of these two functions. In the case of &lt;b&gt;for..in&lt;/b&gt; it will call &lt;b&gt;nextName()&lt;/b&gt;, and for &lt;b&gt;for each..in&lt;/b&gt; it will call &lt;b&gt;nextValue()&lt;/b&gt;.
 Because we're not doing anything complicated in this example, we just return "properties[index - 1]" (remember Array is 0-based, the Proxy functions are 1-based).
 If there were more logic in our &lt;b&gt;getProperty()&lt;/b&gt; method from the first part of this article, then we'd want to defer to that method rather than duplicate that
 login in the &lt;b&gt;nextValue()&lt;/b&gt; method.
&lt;/p&gt;

&lt;p&gt;And that's how you use the &lt;b&gt;Proxy&lt;/b&gt; class. Now, go build something bad-ass with it :)&lt;/p&gt;

&lt;p&gt;&lt;a href="http://files.joshmcdonald.info/flex/BlogProxyDemonstration.zip"&gt;Download source&lt;/a&gt;.&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/3737565678255668197/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=3737565678255668197" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/3737565678255668197?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/3737565678255668197?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/09/using-proxy-class-part-2.html" title="Using the Proxy class (part 2)" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkIAQ30-eip7ImA9WxRTFEo.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-2632613122083258606</id><published>2008-09-04T07:48:00.000+10:00</published><updated>2008-09-04T07:49:02.352+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-04T07:49:02.352+10:00</app:edited><title>Using the Proxy class (part 1)</title><content type="html">&lt;p&gt;When I first came across the &lt;a href="http://livedocs.adobe.com/flex/3/langref/flash/utils/Proxy.html"&gt;Proxy&lt;/a&gt; class, I got 
rather excited. Dreams of mock objects, cross-cuts, and various other cglib shenanigans danced in my vision. Sadly, it was not to be, and the VM doesn't let you cast Proxy as another class (or interface). However, it has its uses, and I'd like to explain how to use it.&lt;/p&gt;

&lt;p&gt;I know it's been done before, but for this example I'm going to re-invent the "bindable dynamic object". The point is to explain the Proxy class :)&lt;/p&gt;

&lt;p&gt;Let's get started:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
[Bindable(event="propertyChange")]
public dynamic class BindableDynamic extends Proxy implements IEventDispatcher
{
    //Actual contents
    private var properties : Object = {};

    //Property names
    private var propertyNames : Array = [];
&lt;/pre&gt;

&lt;p&gt;A few things here:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We've annotated the class with [Bindable(event="propertyChange")]. This marks the class as bindable, and because we 
specify the event name, MXMLC assumes we know what we're doing and doesn't generate any Binding boilerplate for us, 
which is what we want :)&lt;/li&gt;
&lt;li&gt;We've got two private variables here: properties, which holds our actual values, and propertyNames, which we'll use 
as a list of (guess what?) property names!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Flex docs don't use the propertyNames variable, and instead use a temporary array when iterating the fields 
using &lt;b&gt;for..in&lt;/b&gt; or &lt;b&gt;for each..in&lt;/b&gt;, but I like keeping the list around.&lt;/p&gt;

&lt;p&gt;Some more code:&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
//Simple getProperty by name
override flash_proxy function getProperty(name : *) : *
{
    if (!name)
        return undefined;

    if (!(name in properties))
        return undefined;

    return properties[name];
}

//Do we have property x?
override flash_proxy function hasProperty(name : *) : Boolean
{
    return (name in properties);
}

//Set Property
override flash_proxy function setProperty(name : *, value : *) : void
{
    var oldValue : *;

    //Check for existing value
    if (name in properties)
    {
        //We do have one, we need to retrieve it for comparison and a useful PropertyChangeEvent
        oldValue = properties[name];

        //Check to see if there's no change (in which case we're out like 3 stripes)
        if (oldValue === value)
            return;
    }
    else
    {
        //If we're here, then this is a new property (not an update)
        propertyNames.push(name);
    }

    //Set property
    properties[name] = value;

    //Announce!
    dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, name, oldValue, value));
}
&lt;/pre&gt;

&lt;p&gt;These functions are pretty self-explanatory. A couple of things might jump out at you if you're new(ish) to ActionScript though:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The use of &lt;b&gt;flash_proxy&lt;/b&gt; in place of &lt;b&gt;private&lt;/b&gt;, &lt;b&gt;public&lt;/b&gt;, or &lt;b&gt;internal&lt;/b&gt;: In Actionscript, private, public and internal
are simply namespaces (but built in and with special meaning). Proxy uses its own namespace so that its methods don't clash with 
anything you might be trying to intercept. You can also define your own namespaces, and there's an entire blog post (or 8) for 
me to write about &lt;b&gt;mx_internal&lt;/b&gt; and the various fun stuff we can do with it!&lt;/li&gt;
&lt;li&gt;The &lt;b&gt;in&lt;/b&gt; operator: It's not used so much, but I love its elegance. For our intent at the moment, think of it as an analogue 
to &lt;b&gt;.hasOwnProperty()&lt;/b&gt;. There are differences, but for our current purpose either would do, I just prefer it stylistically. 
If you'd like to read more, check &lt;a href="http://livedocs.adobe.com/flex/3/langref/Object.html#hasOwnProperty()"&gt;here&lt;/a&gt; and 
&lt;a href="http://livedocs.adobe.com/flex/3/langref/operators.html#in"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Finally, we dispatch our own PropertyChangeEvent, which is how we let Binding know it's time to do its thing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&amp;hellip;I'll post part 2 tomorrow, where we get to the fun stuff!&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/2632613122083258606/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=2632613122083258606" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/2632613122083258606?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/2632613122083258606?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/09/using-proxy-class-part-1_04.html" title="Using the Proxy class (part 1)" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkMNQX44cSp7ImA9WxRTFEo.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-5847792455699772359</id><published>2008-09-04T07:47:00.001+10:00</published><updated>2008-09-04T07:48:10.039+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-04T07:48:10.039+10:00</app:edited><title>Design...</title><content type="html">...If this looks borked in IE, &lt;a href="mailto:josh@gfunk007.com"&gt;email me&lt;/a&gt;! I've not had the time to test it since I re-jigged some stuff.</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/5847792455699772359/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=5847792455699772359" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/5847792455699772359?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/5847792455699772359?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/09/design.html" title="Design..." /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkcBRHk7fCp7ImA9WxRTEkk.&quot;"><id>tag:blogger.com,1999:blog-2681129917095624740.post-3788105108499630045</id><published>2008-09-01T15:44:00.002+10:00</published><updated>2008-09-01T15:47:35.704+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-01T15:47:35.704+10:00</app:edited><title>[Mixin]</title><content type="html">Trivia: The &lt;a href="http://nondocs.blogspot.com/2007/04/metadatamixin.html"&gt;[Mixin]&lt;/a&gt; metadata is great, I use it all the time when doing framework stuff. Check it out if you've never heard of it, or if you're calling static code some other way. But make sure you only annotate public classes with [Mixin], or your SWF will explode on frame1 inside of SystemManager :)</content><link rel="replies" type="application/atom+xml" href="http://flex.joshmcdonald.info/feeds/3788105108499630045/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2681129917095624740&amp;postID=3788105108499630045" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/3788105108499630045?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2681129917095624740/posts/default/3788105108499630045?v=2" /><link rel="alternate" type="text/html" href="http://flex.joshmcdonald.info/2008/09/mixin.html" title="[Mixin]" /><author><name>Josh McDonald</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_bXyHLseMqbM/SPwssQ_uBlI/AAAAAAAAAB4/pIiJGFC99qY/S220/poseur.jpg" /></author><thr:total>0</thr:total></entry></feed>
