Wednesday, June 27, 2007

Flex 2 - Flash for Programmers

Flex 2 Discovered

Wow. Moving from Flash CS2 to CS3 (with ActionScript 3.0), I was surprised and excited. Now after trying Flex 2 for the first time, I'm amazed. Finally it makes sense to develop in Flash. Since I have completely switched to Flex 2 development, I will no longer post about Flash development. If you have Flash questions, I will still answer them to the best of my ability.


Why Flex is Better for Me

  • I'm not an animator, I'm a programmer.
  • Flex has named "States" while Flash has "frames" and "keyframes" (I know, they can be named).
  • I don't consider applications/screens/UI components as MovieClips.
There are lots of other small reasons for me to choose Flex over Flash. The main one is the development environment. Assuming you've shelled out the $ for Flex 2 Builder, you are now working in Eclipse (yes, that's right -- Flash in a real programming IDE). If you haven't spent all that money and simply have a command line compiler, I'm sure you're still using a good programming IDE. This makes a big difference.


How do you get Started?

If you're looking to write a Web 2.0 application, a nice looking desktop application, a rich Internet component, or a fancy UI component, you've started in the right direction. Finding good programming information can be a little harder than usual in the Flash/Flex world.

ActionScript 3.0 and MXML are your languages. MXML compiles down to AS3 but allows Flex Builder to display components in the editor. Mixing both is ok so don't worry too much if you are doing the right thing.
  1. Get a copy of Flex 2 Builder. Even the 30 day trial is fully featured. I strongly advise this over the compiler-only free version.
  2. Read tutorials, get books, read through Adobe's online documentation.
  3. Of course, check back here for new information.

Your Project

Write components for anything graphical. Even if you aren't going to re-use this component, having it wrapped up nicely keeps your code away from the main application's code.

Use ASDoc everywhere. If you're a Java fan or have used other document generation products, ASDoc will be familiar. Use it, use it properly, and use it heavily.

Write classes and code correctly. Don't write garbage and follow a common format.

UI components should: be able to re-size/reposition based on the window size, have styles, and use events.

Experienced developers can work with interfacing with web services, class hierarchies, and advanced code while junior developers can easily work with user interfaces, UI backing code, and small components.


Concepts

You are forced into using good practices by not allowing direct database access (both a design decision and a natural limitation I'm sure).

Meta data tags (like annotations in Java) are used to extend certain concepts.

After the function keyword, you may place "get" and "set" keywords to mark this function as a getter or setter. This allows simple get/set methods to act like public properties and reduce documentation. Don't forget not to name your variable the same as the method (it is common to place an underscore at the front of the private variable if it is accessed by get/set methods).

The override keyword (placed before the access type "public" etc.) is used to say "I am overriding a super class method." Meaning if it was spelled incorrectly, the compiler will give an error.

If you are familiar with Java, this will help when trying to learn ActionScript 3.0:

http://flexblog.faratasystems.com/?p=115


Coming up...

I hope to post a lot of helpful links to things that developers want and need when working in Flash. Check back often for new links, tutorials, and reviews to help you get ahead.

No comments: