-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Flex 3 with Java

In this chapter, you will learn how to install and configure Basic Flex 3.0 SDK (Software Development Kit) and Flex Builder 3. The Adobe Flex SDK contains everything you need to build and deploy Flex Rich Internet applications (RIAs). You can write Flex programs typically using any freely available text editing tools, such as Notepad, TextPad, or any Integrated Development Environment (IDE) of your choice. Adobe provides a specialized IDE for developing and designing Flex applications known as Flex Builder. Flex Builder is built on top of Eclipse platform. So if you are familiar with the Eclipse development paradigm, it will be very easy for you to use Flex Builder.
Although you do not need Flex Builder to write and compile Flex applications, Flex Builder does facilitate development with powerful tools, such as debugger, profiler, and visual designer apart from what the Eclipse platform offers you.
I prefer using Flex Builder 3, since I use Eclipse a lot for my Java development and I have installed Flex Builder 3 as a plugin to my Eclipse IDE.
I am assuming that you have prior knowledge of installing and configuring software packages on the Windows platform. In this chapter, I will explain how to install Flex Builder 3 on Windows. Mac and Linux users should visit Adobe's web site at http://www.adobe.com/support/documentation/en/flex/3/releasenotes_flex3_fb.html for installation instructions.
Flex SDK comes in different types such as licensed Free Adobe Flex SDK (with a mixture of open source and closed open source components) and open source Flex SDK. The latter package contains entirely open source components under the Mozilla Public License version 1.1 (MPL) agreement, which includes its binaries. To know more about the available types of SDKs, visit http://opensource.adobe.com/wiki/display/flexsdk/Downloads. In this chapter, I will cover open source Flex SDK as an example.
In order to install Flex 3 SDK, download the latest open source SDK from Adobe's web site at http://opensource.adobe.com/flex/. Adobe is continuously working on improving and fixing bugs in Flex SDK and they release nightly builds on a regular basis. You can download them from http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+3 and install them in order to stay updated with the latest feature and bug fixes in Flex 3 SDK.
At the time of writing this book, Adobe was actively working on Flex 4, code named Gumbo. For more information, you can visit http://opensource.adobe.com/wiki/display/flexsdk/Gumbo .
Once you have downloaded the latest SDK in a ZIP format, extract it at your desired location, for example, C:\Flex3.1_SDK
. That's it; you are done with the Flex SDK's installation. Now before you jump into coding, let's first understand the Flex SDK's installation directory structure.
When you install Flex SDK, the installer creates the following directory structure under the installation directory:
Directory |
Description |
---|---|
|
Contains the Flex Ant tasks, which provide a convenient way to build your Flex projects |
|
Contains ASDoc, a command-line tool that you can use to create API language reference documentation as HTML pages from the classes in your Flex application |
|
Contains the executable files, such as the |
|
Contains configuration files, such as |
|
Contains the library (SWC files); you use the files to compile your application |
|
Contains the localization resource files. |
|
Contains the Flex framework source code |
|
Contains the Runtime Shared Libraries (RSLs) for the Flex framework |
|
Contains the theme files that define the basic look and feel of all Flex components |
|
Contains JAR files |
|
Contains the standard and debugger versions of Adobe ® Flash® Player and the Adobe® AIR™ components |
|
Contains sample applications |
|
Contains template HTML wrapper files |
In order to compile your Flex application, you need to set your bin
folder in the Windows PATH
environment variable under your System settings, so that you can use mxmlc
and compc
compilers from your project root folder.
There are a couple of important configuration files that you need to be aware of before you start using SDK. They are as follows.
The flex-config.xml
file defines the default compiler options for the compc
and mxmlc
command-line compilers. You can set and tweak many compiler- and application-related configuration parameters in the flex-config.xml
file located under the sdk_install_directory/frameworks/
folder such as namespaces, library path, accessibility, and locale for application internationalization.
All of the Flex component names are defined in the mxml-manifest.xml
file. This manifest file maps Flex component namespaces to class names with complete package names. This is similar concept as XML namespaces. The mxml-manifest.xml
file is used to avoid element name conflicts and it also helps in organizing your source files. Don't worry about these files right now. You will learn more about them and their usage in a better manner further in the book.
Example:
<?xml version="1.0"?> <componentPackage> <component id="HelloLabel" class="usa.hello.HelloLabel"/> <component id="NamasteLabel" class="ind.namaste.NamasteLabel"/> </componentPackage>
In a manifest file, the id
property of each<component>
tag must be unique. That id is the name you use for the tag in your Flex applications, for example:
<local:HelloLabel label="Hello!"/>
You will learn more about how to use namespaces in Chapter 2 of this book.
The Flex compiler requires Java Runtime Environment (JRE) to compile Flex source code; configuring Java Virtual Machine (JVM) parameters can actually result in much faster and optimized compilation in some cases. Without JRE you cannot use Flex compilers, such as mxmlc
and compc
.
You can configure JVM settings in the jvm.config
file, which is typically located under the sdk_install_dir/bin
folder. The most common JVM configuration you may ever need is the JVM heap size. The Java heap is the amount of memory reserved for a particular JVM instance for faster performance; for example:
java.args=-Xms256m -Xmx512m
Change the font size
Change margin width
Change background colour