Flex Developers Are So Spoiled
I took some time this weekend and helped my wife update her site. I talked her into letting me build a little flex header that displays the photos from her flickr stream. My wife takes a few pictures of our daughter everyday with her iPhone and posts them to flickr, so I thought this would be a neat way to update the site between blog posts.
It took about 20 minutes to through together the first draft. I just grabbed her flickr feed as json and use the corelib to eval it into some objects. Then used mx:Image objects to load the pictures and display them horizontally inside the application.
But this simple swf was 170kb. Now I know that in todays world of fat bandwidth that is just a drop in the bucket, but I saw this as an opportunity to do some AS3 application work without the aide of the mx packages.
The result, after about 2 hours of work is the exact same end product. But it only weighs in at 9kb. While I achieved my end goal in reproducing the flex application, this process was nothing like what I expected. First off… flash has no layout containers! None? As a flex developer being able to set the layout property of the Application or using HBox and VBox to layout components. How the hell did flash developers manage before flex? Everything pixel positioned? You are kidding right? So I wrote a basic LayoutManger and HBox and VBox components that work in AS3 and support basic gap and scrollposition properties. You can see the source for the header and the layout managers here.
Other tricks that stumped me but where easily solved by a quick visit with Ben Stucki, are to set the scale mode and alignment of the swf so that it works like I expect from flex.
this.stage.scaleMode = StageScaleMode.NO_SCALE;
this.stage.align = StageAlign.TOP_LEFT;
Another neat trick was that I have become accustomed to setting height and width on my application and having it sized correctly. In AS3 you can use the SWF metadata tag to set the size of flash player display.
[SWF( height='150', width='975')]
Anyway, after building something without the benefit of the Flex framework, I have a new appreciation for the Flex SDK. So let me just take this second to thank all the Flash developers that have come before me for achieving so much and proving the rest of us with such an amazing tool set. And thanks to Adobe for providing the results that work and knowledge to us as an open source sdk.

Did you try compiling it with Flex 3 and set it to use the Flex Framework as an RSL? I just wondered if that would bring your part of the code down to the same size of the pure AS3 version.
Although obviously you’ll still be relaying on loading a 150k file at some point at least having the framework as an RSL would mean that only happens on the first visit.
Also I agree with you on the fact that Flex developers are spoiled - but that’s the whole point and attraction of the frameworks, lets you concentrate on the application your building and not extraneous stuff that shouldn’t be of your concern.
Uh….Ahem….Talk about making things harder than they need to be!!!! That’s all I’m going to say about this, pure AS3, bah! ;-)
~Tom
You know, I tend to go with the KISS principle as well. And for any application that used binding or data or forms… the size of the framework is a blessing.
For something that is supposed to look like a header on the top of my wifes web page…Its a bit overkill. I mean come on! All I wanted to do was display some silly little images in a row. Why do I need the whole flex framework for that. And at a savings of 19 times the KB, how could I not. :)
But yes, all in all it was overkill, but I learned so SO much about the display list and the render cycle of flash player that it was more than worth it for this experiment. Look at it this way, have you ever called invalidate on the stage of a flex application? Whats a stage right? :P Well I know what that does and how to use it, so neener neener neener! LOL
I have rebuilt RUNNINGMAP.com in Flash probably 4 times the latest being this fall. Now the the Yahoo! AS3 map component release I am going through another rewrite in Flex. I have built other apps in Flex but this one really hits home as to how much easier it is to build APPLICATIONS in Flex. It is a dream compared to what I just went through in Flash.
Yes, in Flash you have to invent your own layout management.
Kudos for building it in AS3. Learning stuff = good and 9kb makes the magic donkey happy.
Count me in the ranks of the spoiled, fat, happy, and Flex-ified. :)
- max
Can you imagine the joy we Flash developers experienced when we saw things like the HBox, ItemRenderer’s, ect? My thought was, “You mean, I just fill this thing up with stuff. And I can move them around, etc, without writing any code. And they won’t fall on top of each other?” Joy-gasm!!!
You’re welcome.
Seriously though, the tools are great to work with; but coming from the Flash side I have a constant nagging feeling that somebody is going to point out to me how spoiled I am now (like you just did). I have to get my hands dirty in pure AS3 now and then so that I can continue to hold my head up high.
Kind of like going back to my parent’s farm to pitch hay to remind me that not everybody has always been able to sit in a comfy chair to earn their daily bread.
You know, I’ve gotten frustrated with some aspects of Flex…such as feeling like I’m writing nothing more than XHTML+CSS and wishing for a better visual experience than the Design view. But just the other day I also realized how incredibly awesome the layout components are. I took a look at my views in progress and didn’t even waste the brain energy to imagine how I would have built such flexible layouts in Flash. Instead, I was only happy I didn’t have to!
And another way we’re spoiled (at least right now)…JOBS!!
I know what you mean, I just spent countless hours building a layout manager, hbox, vbox in actionscript 2. It was pain, but it was worth it. Its kind of like dynamic xml getting rendered at runtime.
The popup forms here use it: http://www.scientology.org