Book Image

Flex 3 with Java

Book Image

Flex 3 with Java

Overview of this book

Flex 3 is a great technology for developing Rich Internet Applications for the Web as well as for the desktop. If you are a developer looking to design great-looking and sophisticated user interfaces that resemble desktop-based applications, and want to utilize an existing server technology such as Java to develop RIAs, this book is for you. Targeting developers who want to get started with Adobe Flex 3 programming, this simple and clear handbook introduces Flex technology quickly and straightforwardly. Utilizing your existing knowledge of Java, it gives you the insight and hands-on experience to program with Flex 3. This book provides comprehensive information on various aspects of Flex 3 and ActionScript 3.0. These include developing simple applications, handling events, creating custom components and events, using RPC services, integration with Java and BlazeDS, styling and formatting, and how to package and deploy Flex applications. You will start with downloading, installing and configuring Flex 3 SDK and Flex Builder 3 and learn basic concepts such as what MXML and ActionScript are, understanding UI components, controls, compilers, and more. Further you will develop simple applications and slowly advance into more depth where you will learn advanced concepts such as creating custom components, debugging, integrating with Java, using RPC services, styling, internationalizing, and deploying Flex applications, and more. One of the things you're really going to love about this book is that you will develop a full-blown e-commerce application using a combination of Flex 3, ActionScript 3.0, BlazeDS 3.2, and Java. At the end of the book you will have the knowledge and experience needed to develop Rich Internet Applications.
Table of Contents (18 chapters)
Flex 3 with Java
Credits
About the Author
About the Reviewers
Preface
8
Communicating with Server-side Java

Flex compilers


Flex SDK is bundled with two command-line compiler tools—one for compiling component library SWC files and the other for compiling executable Shockwave Flash (SWF) files.

The SWC files are Flex component archive files that include compiled binaries and embedded assets of a component. The SWC files can be referenced by Flex application as the external library of component definition. You can think of SWC files as JAR files in Java. To read more about the SWC format, visit http://livedocs.adobe.com/flex/3/html/help.html?content=building_overview_5.html.

The SWF files are complied binaries of Flex application. Think of these files as executables of the Flex applications which are executed by Flash Player either inside the Internet browsers or standalone Flash Player. To read more about the SWF file, visit http://www.adobe.com/devnet/swf/.

Using compc—the component compiler

You use the component compiler to generate SWC files from component source files and other asset files, such as images and stylesheets. The SWC files are more like the .jar files in Java. They are typically used as library files in a Flex project.

This is the general compc syntax:

compc -namespace http://www.mynamespace.com manifest.xml
-source-path .
-include-namespaces http://www.mynamespace.com
-include-classes com.mycomponents.Component1 com.mycomponents.Component2
-include-file icon.png mx/containers/icon.png
-output=bin/MyComponents.swc

Note

Type the preceding command on a single line. It appears here on multiple lines for the sake of clarity.

You can use the -namespace and -include-namespaces options to include any number of components. This can keep the command line from being untidy.

The source-path option includes the current directory in the source path. This is how compc finds the various classes that are listed in the include-classes option.

The output option specifies the output location of the SWC file. In this case, compc writes the MyComponents.swc file to a folder named bin.

The include-classes option specifies the classes that you want to include in the SWC file. The compc component compiler is typically used in Flex for creating an external components library that can be referenced into Flex application or for creating Runtime Share Libraries, and so on. This is different from the mxmlc application compiler, which generates a Flex application executable.

Using mxmlc—the application compiler

You use the mxmlc application compiler to compile your Flex application source into an SWF binary file. The SWF files are executables of the Flex application that are executed into Flash Player. You can use the SWC files generated by component compiler, that is compc, when compiling MXML files. You typically use the library-path option to specify which SWC files the application uses.

This is the general mxml syntax:

mxmlc -library-path+=..../MyLibraries/bin/Main.mxml

The -library-path option includes the SWC files from the MyLibraries/bin folder for referencing any component referenced inside Main.mxml. For example, if Main.mxml is referencing any component which is part of the MyComponents.swc file, then you will need to include MyComponents.swc into the -library-path option. This is similar to what you do by including JAR files in -classpath while compiling the Java source.