Book review of Flex 3 with Java

Monday, 29 March 2010

note: This review is yet to be completed. Chapter covered so far: 1, 2, 3, 4 and 6.

I requested a reviewer's copy of Flex 3 with Java from Packt publishing because I occasionally program in Flex 3 (mostly to create graphs and charts for web apps). I almost exclusively program in Python and I was curious to compare the the Java/J2EE code with my own past experience.

Chapter 1

The first chapter goes into installation and configuration details. How to install the Open Source SDK (which is released under Mozilla license).

The installation instructions are windows specific. But, Flex3 being a java application, there is not much difference in the way Flex is installed.

There are two compilers that are used in compiling a flex application -- mxmlc, the most commonly used application compiler and compc -- the component compiler.

The chapter continues on about installing the Flex builder 3 (built on eclipse and available as a eclipse plugin, and NON-FREE). The Flex builder can be handy if you are new to Flex. The UI designer and the autocomplete can be a big help in learning Flex3.

Chapter 2

The second chapter is gives a good overview of the Flex3 framework. Flex3 applications are written in a mixture of MXML ( the layout language, which is XML) and Actionscript, a Javaesque language with some oddities. I assume some of the language idiosyncrasies are a legacy of Flash scripting days. Broadly speaking, MXML:Actionscript::HTML:Javascript.

The attraction of MXML/Actionscript combination over HTML/Javascript is the near universal gurantee of your Flex application looking the same across all browsers and operating systems. Flex3 also gives you a desktop like programming experience. The chapter covers layout strategies, event handling, data binding, user input validation and custom item renderers. Custom item renders allow the programmer to alter the behaviour of data display elements like lists, data grids etc.,

Chapter 3 ActionScript 3.0

Actionscript is a fairly familiar fair to most programmers coming from Java/C# background. AS3.0 is based on ECMAScript and is standards based.

Actionscript 3.0 introduces strict data typing, improved runtime exception handling. AS3.0 treats XML as a native data type and manipulate the data without writing XML parsers or defining DTDs.

I was surprised to find that AS3.0 has support for regular expressions. This is something I'd not considered looking for in a statically typed language like AS3.0. However, this book does not carry have of examples Regular expressions using AS3.0. An example comparing RE syntax with that of Perl/Python/Ruby would have been nice.

Chapter 4 Talking with Javascript using External APIs

Flex applications, especially business applications are often built as stand alone web applications. That is, the entire user interaction is with the flex app embedded in the web page with no HTML or Javascript. While there are some uses for this approach, more often than not, using Flex as an embedded compoenent/widget is a more practical approach. The External API, exposed via the ExternalInterface class allows two way communication between Actionscript an Javascript. This allows you to AS objects from JS and JS functions from AS. This is a very useful feature that I'd not seen in Flex related articles and documentation.

LocalConnection class allows you to communicate between Flash objects embedded in the same web page. The example given in the book looks straight forward enough. I do not recall having a good experience of using LocalConnection to call a Flash object from a Flex object.

Chapter 6 Data Services

As a Python programmer and thus forced to use only AMF3 (using PyAMF), I was keen to learn more about BlazeDS and LiveCycle Data service. This chapter is really light on the specifics of using data services with flex. Code examples of how BlazeDS and LCDS make life easy for a developer would have been very useful.