*

2007 / April 9th/ Revisiting Flex

A while ago I hinted that I was taking a second-glance at this whole web-publishing business and trying out Flex. So far, it’s been an overwhelmingly positive experience. There have been some highs, some lows, and some wow-that’s-weird moments. It really has made me step back and remember that HTML and CSS isn’t the one-and-only — it’s merely a means to an end for displaying your information.

So far, I’ve built a few pieces here, skinned a few things there and came out with an XML-powered flash video player that encompasses a lot of other neat logic, like built-in commenting / reviewing too. Here’s a recap of my experience so far.

Highlights

  • The “baked in” features like VideoDisplay actually work and are extensible making them much better than other features I’ve seen that you end up never using — like Rails’ scaffolding.
  • It’s truly wonderful having baked in ideas for things like asynchronous requests, web services, xml data models and the like. No more ugly DOM hacking. Stuff like E4X makes working with XML thousands of times easier.
  • Flex Builder is actually very, very nice. It’s the nicest IDE I’ve ever used (which I usually run away screaming from). I ended up picking me up an academic version since I’ll just be playing around with it (unless I use it at work; which will require a new license). Academic version was $80 with charting. Retails for $750 (ouch).
  • States! My god, these are amazing. It’s a hard concept to describe, but it’s basically a “page” in HTML. Except it’s done fantastically. Love it, love it, love it.
  • Familiarity with Javascript. Everything feels pretty similar — I especially love how event handling just works in Flex. It’s a nice change of scenery.

Pitfalls

  • Strong-typing. Ugh. I’ve never “really” used a strongly-typed language and end up doing nasty things like this (this can probably be done better)

    public function formatTime(num:Number):String{
            var seconds:int;
            var formatSeconds:String;
            var minutes:int;
            seconds = num%60;
            minutes = (num - seconds)/60;
            // formatting (lame)
            if (seconds < 10){
                formatSeconds = seconds.toString();
                formatSeconds = "0" + formatSeconds;
            }else{
                formatSeconds = seconds.toString();
            }
            return minutes.toString() + ":" + formatSeconds;
        }
    
  • Very lose separation of content from presentation. Could use better CSS support.
  • CSS selectors are lame, at best. Can only target root-level elements and singular styleName (basically a class). No inheritance or cascade that I can tell.
  • Some strange layout-rules that require many “layers” so to speak — boxes within canvases within boxes, etc.
  • While awesome in implementation, the idea of your XML elements being ActionScript objects is a bit akward at first. Very weird to see something like <mx:AddChild relativeTo=”{container}” position=”lastChild” /> in your code.

Room for improvement

So what would make Flex even better? Here’s my short-list.

  • Enable scripting language support: If we could get something like a Ruby bridge for ActionScript, I’d be in heaven. I’m not sure the mechanics of doing this, but something like RubyCocoa for ActionScript would be beautiful.
  • Let’s get some more CSS support: CSS is actually pretty darn good at laying out objects. Flex tries with this, but leaves out some key players like line-height, margin, position:relative, etc. Also the idea of absolutely positioned elements inside relatively positioned elements would go a long ways for allowing less wrappers in Flex.

Getting started

If you’d like to get started with Flex, you can go ahead and download the 30-day trial of FlexBuilder, which includes the Flex SDK (the thing that actually compiles everything into an SWF, which is free). After that, I’d recommend reading through Adobe’s Getting Started with Flex 2, and then moving on to their other documentation — it’s actually very well documented.

A word from the sponsors. Advertise with Warpspire

5 Comments

comments feed

  1. Gravatar
    Thomas Aylott

    April 9th | #

    I’ve been considering what tech I’m going to be moving into next. Should I go with Flex and AS3 or go whole hog into “real” application development with ObjC…

    I think Flex may be the way to go, unfortunately.

    I say ‘unfortunately’ since I really hate the concept of recreating a gui inside another gui, especially since the Mac OS X gui is so very very nice. I suppose I could always skin the Flex UI elements. But I guess you have to take it asis and make the best of it.

    Anyone out there planning on writing a RubyFlex?

  2. Gravatar
    Cole

    April 9th | #

    This one definitely qualifies as “ignorance”. How is the user-end of Flex implemented? Is it like Flash Player but “Flex Player” instead? Is it cross compatible?

  3. Gravatar
    Kyle

    April 9th | #

    The user-end of Flex is delivered as a compiled SWF. It’s all through flash — so all the same compatibilities there. But the authoring environment and method is 100% different than flash.

  4. Gravatar
    Thomas Aylott

    April 9th | #

    From what I understand. Flex is just an actionscript framework for flash. Kindof like dojo is a javascript framework and ruby on rails is a Ruby/Web framewwork.

    The end result of Flex is just a normal flash file.

  5. Gravatar
    M dog

    April 11th | #

    $up DoggI3z.
    A Lil’ aboot mi, D3zInE Is PreDDy Much My ting’

    For Realzies bizznizzles,

    I have had extensive experience in web design. I am better than all yall fools at what i do zzizzzzlze. I am willing to say that without a doubt, going back to my roots with HTML has allowed me to really realize that good code is like the ACTUALLY HAVING lube on hand when you need it…right guys, am I right?…Anywayzies, Flex is tighter than a German Virgo, and it was nice meeting yall.

    Please visit my site. I am mostly here for networking.

    P.S. I think this site copied some elements straight from my code. I probbles shuda hidded that much bezzeddar (cheese, that is).

    Peace in the middle east!

    M Dog

Make a Comment

don’t be afraid, it’s just text

Comments are parsed with Markdown. Basic HTML is also allowed.