Flex is a highly productive, free open source framework for building and maintaining Flash interface applications. FusionCharts for Flex can either can be implemented through Adobe Flash Builder (previously known as Adobe Flex Builder) or through the open source Flex SDK. So, if you don't want to invest in Adobe Flash Builder, you can still integrate FusionCharts with your Flex applications with the help of the free SDK. All you need to do is - write your MXML file using the FusionCharts code and use a simple mxmlc command to create an SWF file comprising of FusionCharts objects.
FusionCharts and FusionWidgets have been integrated with the Flex development environment as an external library module. For this example case, we are assuming that the folders libs
and src
are present within the project root. And, the MXML file is present in the src folder. All subsequent instructions are based on the presumption that this directory structure is present. And, that you have installed Flex SDK and the path to the mxmlc compiler has been specified in your operating system's PATH variable.
To compile an application using Flex SDK, you have to use the mxmlc compiler. The compiler can be obtained from the bin folder of the Flex SDK directory. In the mxmlc example discussed below, the application's MXML file will have no external dependencies (such as components of the SWC file or ActionScript classes). So, you have to change the present working directory of your project root (referenced as PROJECT_ROOT
from here on) from the command line. Next, run the mxmlc from the command line and point it to your MXML file (we have assumed the file name to be FusionCharts.mxml), as shown in the following example:
mxmlc src\FusionCharts.mxml
To use FusionCharts with Flex SDK, you must import the libraries to your project. The following steps will guide you through the process of importing FusionCharts files to your project:
DISTRIBUTION_ROOT/Charts/swc
to PROJECT_ROOT/libs
folder. The DISTRIBUTION_ROOT
is the location where you've extracted the downloaded FusionCharts for Flex archive.fusioncharts
and fusionwidgets
folders from DISTRIBUTION_ROOT/Charts
to PROJECT_ROOT/src
folder. These folders contain all the Flash chart/widgets objects.The FusionCharts.swc file acts as the library for both FusionCharts and FusionWidgets. It allows you to add charts from the FusionCharts pack and widgets (gauges and charts) from the FusionWidgets pack. The FusionWidgets functionality was added to the SWC in version 1.1
Now, you are all set to write the code for implementing FusionCharts for Flex. For a quick reference on coding, please visit Your First Chart section.
After importing the necessary library files and updating the MXML file with FusionCharts code, you are now capable of incorporating FusionCharts into your applications. The following command recompiles the files with the help of the FusionCharts SWC library:
mxmlc -library-path+=lib\FusionCharts.swc src\FusionCharts.mxml
The library flag is used for declaring one or more libraries. In this case, the library is FusionCharts.swc. After the command is executed the required SWF file comprising of FusionCharts components is generated.