Programming + Design

Moving From Flash 8 to Flex 2: Day 3 PDF Print E-mail
Written by Brett Brewer   
Monday, 20 August 2007
Learning Flex2 has been a real eye opener for me. For anyone who is familiar with the older Flash component architecture (v1 and v2), you will be happy to hear that the new component architecture is much more robust and easily extended. Flex2 authors Flash9 movies with Actionscript 3. The authoring environment is based on Eclipse and existing Eclipse users can keep using Eclipse with the Flex2 builder plugin for Eclipse. Having spent countless hours configuring Eclipse for use with PHP, I chose to use the Flex2 Builder. The standalone Flex Builder appears to be very similar to Eclipse and I think it was built largely on Eclipse, so it will get you used to the Eclipse IDE conventions should you ever decide to use the full version of Eclipse.

The course I'm using to learn Flex2 is the "Total Training for Adobe Flex 2 - Rich Internet Applications by James Talbot. The course is great, but I must say that I have been surprised by the speed of the lessons. I barely have time to keep up with the instructor while I'm following along. I suspect that anyone who isn't a really fast typer or who isn't very familiar with AS2 will spend a lot of time rewinding and rewatching each segment. In addition to covering some of the basics, the course focuses on best-practice solutions for things like data binding, custom event classes and general MVC application architecture concerns. If you are a Flash actionscript programmer that has never taken a real programming class, Flex2 is probably going to hurt your brain. It might be a good time to go enroll for a semester at a local community college where you can take a C++ or Java course. Java would be especially appropriate as a primer for Actionscript3. According to the author of the course I'm taking, "Actionscript 3 is as close as you can get to being Java without actually being Java." That means being comfortable working with Objects and Events. Most of the course has been focused on various ways of setting up objects, and broadcasting and responding to events.

Now that I've had a chance to build a couple of simple Flex2 applications as part of the training course, my first impression is that this is going to eventually make my life much easier when developing Flash apps. In particular, I am much more likely to write applications using the built-in component libraries which can now be much more easily extended than the previous generation of Macromedia components. It is also a breeze to create your own custom components derived from the existing components...Flex2 will even help you write your custom component classes by providing starter templates based on existing components.

Many Flash8 developers who have wrestled with customizing the DataGrid component, will be happy to hear that Flex2 makes writing custom cellRenderers and itemRenderers a total breeze compared to the old way, so now it is a simple proposition to have a datagrid with multiple data types and components embeded within a datagrid cell.

Unfortunately, it looks like there are still problems with some of the underlying display mechanisms of the built-in component architecture. For instance, I have yet to see a "smooth scrolling" implementation of a datagrid, repeater or tile list. I'm beginning to wonder if it's technically impossible in Flash, or if the component architecture is simply to blame. Without smooth scrolling, Flash interfaces that are built with the UI components will always have a certain element of clunkiness.

I have not yet delved into the offical online documentation, so I'm still hoping it has been vastly improved for Flex2 since the online Flash docs have always been completely useless to me as a developer. I have never found an answer to a question in the online Flash docs. If you want to see a great online documentation system, check out If you have a question about any function in PHP, you just go to and you'll get the official docs on that function name, plus a whole page full of user-contributed examples of the function being used to solve real world programming problems. No, they are not always the best solution, but there is almost always something useful there. I wish I could go to or and get that kind of useful info. I just don't get why this is such a difficult proposition. A documentation system doesn't have to be fancy, it needs to be easy to navigate and full of useful examples. That's it. But I digress.  

Aside from getting used to event-based object-oriented programming, it looks like the hardest part of Learning Flex2 will be simply memorizing all the different built-in events as well as becoming  familiar with the strengths and limitations of the v3 component architecture. If the past is any indication of the future, knowing when NOT to use the new components will probably be just as important as knowning how to use them.

And let's not forget about the debugging in Flex2. The days of building your apps and praying you didn't need a debugger are officially over. The debugger in Flex2 seems to be on par with what you'd expect from a real IDE, another side benefit of building the Flex2 IDE on top of Eclipse. You get real compile-time errors that let you jump directly to the problem, you get real breakpoints and real step-by-step debugging with access to the call stack. Watch variables are easy to set up. In general, it's a joy debug a Flex app compared to debugging in Flash8. 

Of everything I've learned so for, I think the most important thing has been learning to bind a component's data provider to an ArrayCollection rather than an Array . This is because an ArrayCollection contains all the hooks to catch events that are needed to update the data in any components that might be bound to the ArrayCollection without you having to worry about repainting their interfaces or manually responding to update events. Now THAT is useful!

So hopefully I'm not only learning a new way to write Flash apps, but am also learning some best practices in the process. In short, I highly recommend the "Total Training for Adobe Flex 2" course. I've still got a few more units to go and then I can start applying what I've learned and try to rewrite one of my Flash8 apps in Flex. Joy.

Last Updated ( Monday, 20 August 2007 )
< Prev   Next >


Who's Online

© 2017
Joomla! is Free Software released under the GNU/GPL License.