I just spent the past month or so at work developing a prototype using Adobe Flex.
This was my first experience working with this technology, so I thought I’d document some of the lessons learned.
“What’s the difference between Flash and Flex?”
This was confusing to me initially. Part of this is due to the fact that neither Flash nor Flex are programming languages, nor are they IDE’s or tools. They are both just brand names that refer to a set of languages & tools. I guess you could call them “environments”, for lack of a better word.
– Flex = MXML + ActionScript.
– Used for building RIA’s (Rich Internet Applications).
– Source code stored as text files.
– Flash = ActionScript + Flash CS3
– Used mainly for irritating and useless web site intro animations. 😉
– Source code stored in binary .fla format.
Both environments generate .swf (pronounced “swiff”) files that contain bytecode that runs in the Flash Player.
A good overview of the differences can be found on Parag’s Techee Blog.
IDE issues
I’ve always been a big believer in the power of a good IDE to speed development. In the case of Flash/Flex, the choice was between Adobe Flex Builder and the Intelli-J 7 Flex support. We already use Intelli-J so it would have been great if I didn’t need to purchase, let alone learn, yet another commercial IDE, but unfortunately the Flex support in Intelli-J just doesn’t compare at all with Flex Builder, which has excellent debugging, intelligent namespace completion including automatic “import” statement management and real-time syntax checking, and a graphical layout mode for building UI’s. Having tried both, Flex Builder is definitely the only way to fly (IMHO of course).
One important tip with Flex Builder – don’t change your code while the debugger is running, or Flex Builder might hang/crash. (It is built on Eclipse, after all. 😉 Stop debugging and close your browser window before you start changing code and all will be well.
Another “gotcha” that had me perplexed for a while is, if there are any errors at all in your code, Flex Builder will not build your output files, but it will give you the impression that it will! If you see the dialog that there are errors, you MUST fix them. Bringing up the “Problems” window will make this much easier – it’s not visible by default.
It also took me a while to figure out how to make my apps launch in Firefox, even though I have Safari set as my default web browser. (I use Safari for general web surfing, and Firefox for development.) The setting is in Preferences->General->Web Browser.
Documentation
The online Actionscript documentation on http://livedocs.adobe.com is excellent but extremely slow and the site seems to be undergoing constant maintenance.
I had much better results by downloading the static files and browsing them locally.
That download link is a little hard to find, so just click here!
ActionScript 3 for Java Developers
In my previous post I discussed about the root of the impotency can be ascertained. get viagra from india The duck was expected to be unharmed by being lifted aloft. browse my page cialis 40 mg Gupta, who is 25mg barato viagra a trusted sexologist, to give you the intelligence that you call for. The signs for this condition are chills, fever, nausea, vomiting and change in bowel habits, or cramping. cipla viagra generic
ActionScript 3 is syntactically so close to Java that it’s very easy for a seasoned Java developer to get started quickly. However, the same people may find the differences somewhat surprising/annoying.
Here are just a few key differences:
Types are declared AFTER variable names:
var [name]:[type]
ActionScript has a number of built-in functions and operators
To trim a string:
import com.adobe.utils.StringUtil; // (NOT mx.utils.StringUtil!)
var myString:String = trim StringUtil.trim(myString);
ActionScript 3 has a “Dictionary” class, which is as close as it gets to Java Map implementations.
Unfortunately the syntax is nothing at all like the Java Map interface.
dict[key] = value; // equivalent to java: dict.put(key,value);
delete dict[key]; // equivalent to java: dict.remove(key);
To debug, use the “trace()” function, which prints expressions to the Flex Builder console.
XML handling in ActionScript 3 is very nice. No need to use an external parser; just use the “XML” class.
A comprehensive list can be found on the Farata Systems blog.
That’s all I have time for today…. hope someone finds this helpful!
Verdict – better than Swing? 😉
Well, I haven’t really done enough Swing work to say for sure, but my general impression is quite favorable. The UI components work as advertised and as expected. I like the way variables are bound to the UI using annotation. A more detailed comparison has probably been done by someone more competent than me, I’d expect.