Hi, I'm Ben. This used to be my blog.
It is now an archive, so comments are disabled.

Flash Camp Orlando is in 3 weeks!

The events formerly known as Flex Camps have been rebranded as Flash Camps to better reflect their position as part of the Adobe Flash Platform. Flash Camp Orlando will include sessions on Flex 4, Flash Catalyst, Adobe AIR, User Experience in Rich Internet Applications, BlazeDS, and much more. If you are in or around the Orlando area I would highly recommend attending this event. It really is a steal when you look at the content provided for such a great price.

Check out the list of speakers and sessions, and tickets are only $35! (Early registration has been extended until May 15)

Sounds pretty good huh? Register Now!

Smooth Scrolling Flex List

Smooth scrolling is a pretty common request for the List component in Flex. Flex Team engineer Alex Harui provided a working, albeit unofficial, example a while back. Michael Ritchie recently ported that example to HorizontalList. I’ve been sitting on some code for a while now and Michael’s tweet on the topic convinced me to finally post my take on the subject.

While in San Francisco for Adobe MAX last November, I volunteered to help out another team from Universal Mind on a project. The task I was assigned was to make a smooth scrolling List. The List had to support variable row heights, which meant Alex’s implementation wasn’t an option. The List also had to support drag and drop, which meant writing my own list component from scratch wasn’t feasible either. I was basically left with only one option: cheat. What I ended up doing was to create a List that would ensure that it was always tall enough to create and show all of its renderers. Wrapping that in a Canvas would then simulate smooth scrolling by utilizing the Canvas’s scroll mechanism instead of the List’s.

Check out the demo (view source enabled) or go straight to the source.

It would obviously be a bad idea to use this if your dataProvider had a ton of items in it, but for most use cases it should work pretty well. The code is pretty straightforward and heavily commented so I won’t rehash everything here. If you have questions feel free to post a comment.

Enjoy!

Fx prefix – Help Adobe make the right decision

If you’re even remotely involved with Flex development, you’ve likely heard about this issue. You’re probably sick of hearing about it, just like I am. Fortunately, the issue will be effectively closed in the coming days. Adobe has stated that they intend to make a final decision this week. That being the case, I am making one final statement on the issue.

You don’t have to look hard to know that the community overwhelmingly hates Adobe’s proposed decision to prefix the name of new components with Fx. FxButton, FxCheckBox, FxResize (yes, effects too), etc.

The technical aspects have been covered ad nauseum and I don’t intend to rehash them all here. There is nothing technical in nature forcing Adobe to prefix the class names. Its really not even that tough of a problem and, as others have pointed out, the Flex team is a large group of extremely smart people. I think its pretty obvious this issue stems from a push from the business side of Adobe that wants a new product released in a certain timeframe in order to drive revenue. I completely understand this and don’t fault them for it one bit. Flex is Adobe’s product and they can do with it as they please but if they start making decisions that sacrifice aesthetics, readability and architectural purity, it will be a product I have much less desire to use. I know I’m not alone in feeling this way, so make sure you let Adobe know what you think.

What the Flex? – HierarchicalCollectionView

If you’ve ever used an AdvancedDataGrid, chances are you’ve encountered HierarchicalCollectionView. If you’ve ever used an AdvancedDataGrid for anything remotely complex, chances are you’ve cursed and shaken your metaphorical fists at HierarchicalCollectionView.

There are likely myriad reasons to despise this class but the one that burned me was this gem: any filterFunction applied to your HierarchicalCollectionView is also applied directly to your underlying child collections. In case the ramifications of that are not immediately clear, what it means is that you cannot simultaneously have two distinct views of a single data set that you have wrapped into a HierarchicalCollectionView. In fact, once applied you will have to manually clear the filter from underlying collections in order to get them back to normal. Because of this, the class is of extremely limited utility, and I would submit that its name is highly misleading. The ‘View’ at the end of the name implies that it will be creating a “virtual” view of the underlying data, leaving the source intact. This is how the immensely useful ListCollectionView class works. Apparently, other languages/frameworks also have “collection view” classes that do not modify the underlying data, so this is quite a departure from convention, not to mention common sense.

If you happen to look at the docs for HierarchicalCollectionView you will notice that filterFunction isn’t even listed as a supported property. Maybe the thinking was if they don’t tell anyone about it, we’ll overlook how poorly implemented it is?

Share your thoughts on the Fx prefixes in Flex 4

Adobe has made the decision to prefix all skinnable components in Flex 4 with the letters Fx, resulting in class names like FxButton, FxCheckBox, etc. They have also stated that if community disagreement were strong enough they would consider reversing this decision. Please use this form to submit your opinion.

http://bit.ly/AxeFx

Spread the word and make others aware of the form as well. The more responses the better.

Update: Manish Jethani, former Flex Team engineer, has written a post detailing why this is such a bad solution. Its really great to see this, not only because I obviously have a lot of respect for Manish, but also because his post is what I would have written if I had the time. He lays out an argument virtually identical to the one in my head, but I think it carries more weight coming from him. So thanks for the backup Manish, and to everyone else, go read it!

Update 2: I’ve made the results sheet public so anyone can view it. Check it here. Note this does not mean the survey is over, just letting everyone see results as they come in. Sorry its just a spreadsheet, blame Google.

Custom IList implementation to flatten hierarchical data

I recently needed to show a set of hierarchical data in a Flex List component. By default, the List component displays a one dimensional, or flat, set of data. In my case the hierarchy was to be shown by displaying the top level objects as dividers with a different visual appearance than their child items. The wrong way to do that would be to create a whole new list that is flat, with some artificial property to differentiate top level objects from children.

I remembered hearing Deepa talk about some sort of virtual lists at MAX 2007, so I started Google-ing. Turns out she was talking about IList implementations. Unfortunately, her examples and every other example I found demonstrated using IList to virtually merge two separate, but related lists of objects. This wasn't what I needed, but it put me on the right track.

As it turns out, the only parts of IList you have to implement are the length getter and the getItemAt() method. I realized that by having control over getItemAt(), you could essentially hide what your list actually contains and return whatever you want. The result is FlattenedList (source). For the lazy and impatient (that includes me) I have included the two most important pieces here:

public function FlattenedList( items:Array, subCollectionFieldName:String )
{
    // store master list
    this.items = items;
    this.subCollectionFieldName = subCollectionFieldName;

    // the first grouping will obviously start at zero
    topLevelObjectIndexes.push( 0 );

    for each( var obj:Object in items )
    {
        // create internal length var to hold total number of items, regardless of level
        _length += obj[ subCollectionFieldName ].length + 1;

        // the next grouping will begin at the index equal to the total number of items already counted
        topLevelObjectIndexes.push( _length );
    }

    // remove last entry since its for next grouping, which doesn't exist
    topLevelObjectIndexes.pop();
}

public function getItemAt( index:int, prefetch:int = 0 ):Object
{
    // iterate over our list of index dividing points
    for( var i:int = 0; i <topLevelObjectIndexes.length; i++ )
    {
        // if the requested index is between the current and next stored index
        // or we've reached the last stored index, use this top level object
        if( index>= topLevelObjectIndexes[ i ] && ( index <topLevelObjectIndexes[ i + 1 ] ||  i == topLevelObjectIndexes.length - 1 ) )
        {
            // get a ref to the top level object
            var topLevelObject:Object = items[ i ];
            // get the "local index" that will be applied to selected top level object
            var indexDelta:int = index - topLevelObjectIndexes[ i ];

            // if requested index is equal to stored start index we return the top level object itself
            if( indexDelta == 0 )
            {
                return topLevelObject;
            }
            else // otherwise we return one of its child objects
            {
                return topLevelObject[ subCollectionFieldName ][ indexDelta - 1 ];
            }
        }
    }

    return {};
}

The code is heavily commented and fairly straightforward so I won't try to explain it here, but take a look and see what you think. I will provide some disclaimers that I only implemented as much as I needed, so there are several unimplemented IList methods in the class. I did implement toArray() because its required to support sorting and filtering. I suppose a better approach might be to subclass an existing IList implementation and just override what you need. As it turns out, ListCollectionView is the only IList implementation in the Flex framework and its a great class that will probably be the subject of a future blog post here.

Lastly, it probably wouldn't take much tweaking to allow FlattenedList to support an infinite/variable level of nesting versus the single level it supports right now. Anyone out there up for a challenge?

Feedback from my session at 360|Flex San Jose

So in keeping up with tradition and the transparency philosophy of our gracious hosts, here is the feedback provided by people who attended my session last month at eBay.

Overall I am pretty happy in that it seems like it was mostly well received. Just like last time I got both "too advanced" and "too basic" comments, which I suppose is to be expected from an intermediate session. I also got confused with Ben Stucki one more time, which happened to both of us more than once at the conference. Its all good though, Stucki is a genius.

I (again) apologize for finishing so early, when I gave the same presentation in Atlanta there were lots of questions during the session and we ended right on time. Not having that aspect really threw things off and in the future I will make sure to have extra content prepared just in case.

I really want my next presentation to be a lot more advanced and code-centric. I'd love to not even have slides, but I think that could be risky too, who knows. I haven't thought of a topic yet, so if you have any ideas or requests send 'em my way.

Thanks a bunch to everyone who attended and everyone who provided feedback!

The obligatory 360|Flex recap and my presentation files

Another 360|Flex has come and gone and once again I'd say it was a rousing success. The conference returned to its San Jose/eBay campus roots, with the majority of attendees lodging at the Holiday Inn down the road.

First things first, my presentation files. My slides can be found here, the sample app I showed (with view source enabled) is here, and you can even "watch" the presentation (audio + monitor capture) on AMP by following the instructions here.

The room was packed to the gills full of people for my session which was very cool, but I only had 2 or 3 people tell me they liked it so I am interested to see what the feedback from the AIR survey app will be like. Unlike 360Flex Atlanta I had very few questions while going through the material and ended up finishing about 40 minutes early! Luckily we spent about 20 minutes on the dedicated Q&A at the end and so we finished only about 20 minutes early. You are also more than welcome to leave feedback here should you so choose, good or bad.

Good sessions

There were 3 sessions that really stood out for me and that you should definitely check out on AMP once they're available. The first was Renaun Erickson's session on his TestPoint approach to testing your Flex apps. Testing is one of those things everyone knows they should do but a lot of us don't get around to implementing in the real world. Renaun's approach is so different that it really eliminates most of the effort involved in testing your app, especially the upfront costs. I won't try to explain it all here but your test cases are essentially created for you as a byproduct of developing your application as you normally would. Its a very clever, very cool approach and one I fully intend on investigating further. I also got a chance to chat with Renaun for a while on Wednesday afternoon about everything from AS1 to general programming philosophies. Its always nice to meet someone you've respected and read material from online for a long time and find out they're a down to earth, friendly person in the real world.

Another session I wholly recommend was Ben Stucki's How to Build a Framework, which is already available on AMP. I especially enjoyed the beginning portion of Ben's talk where he covered somewhat amorphous, theoretical aspects of development that resonated strongly with me personally. As the session progressed things got more concrete and I picked up a few gems I can directly apply in my code. My favorite was his advice to provide an interface, but to not implement that interface in the base class you provide. I know that doesn't convey the whole point so go ahead and check out his session on AMP.

Lastly, I really enjoyed Mike Nimer's session on dpHibernate. I have started to experiment with Hibernate lately and he gave a good introduction to it before diving into the very cool project he and others have developed to bring lazy loading support to BlazeDS. This is another one absolutely worth checking out on AMP once its available.

Good people

This being my third 360|Flex event, its always great to reunite and catch up with people you only get to see a few times a year. This event had the added bonus for me of meeting several people I've been working with on my latest project for Universal Mind. I also finally got to meet my boss and our CEO. Pretty funny considering I started with UM six months ago LOL. I continue to be impressed with the quality of people our company is comprised of, not only in the sense of technical and/or business acumen but in basic quality of character. They're simply good people who I am proud to consider friends as well as colleagues.

Thanks for another great event, Tom and John. See everyone next time!

Flash Player on OS X bug in need of votes

I submitted a bug a while back titled KeyboardEvent.keyCode value is decremented by 64 when Control key is down on Mac and it seems to be languishing in the purgatory that is Community status. While the title is pretty self explanatory, what it boils down to is that adding keyboard shortcuts to your Flex application can become quite tricky if you plan on supporting Mac users.

Particularly troublesome is the Q key, whose keyCode is normally 81. Thanks to this bug, Ctrl + Q returns a keyCode of 17. Problem is, 17 is also the keyCode for Ctrl by itself, and for Command by itself. Discerning between the two is more or less impossible, which sucks.

Can I get some vote love from the community?

360|Flex starts a month from today and you should go

Yep, in just one short month the best Flex conference around will kick off its fifth installment in San Jose, California. Its almost silly how much I look forward to these things but they are just that good. Great people, great sessions and great parties (where a good lot of the best conversations happen) is just something you can't pass up. Especially for under $500! Besides, you can talk your company into paying right? I guarantee you will come back a better developer.

I am honored to be speaking at this event again, especially when you look at the unbelievable speaker lineup as a whole. Check out just this small excerpt:

If that's not a list of industry experts I don't know what is. In fact, if those people aren't in your blog reader shame on you. :)

So seriously, make it to the event if becoming a better developer and making some new friends is anything you're interested in. I promise you won't regret it.

Register Now!