<< Chapter < Page Chapter >> Page >

Download anduse the free open-source Adobe Flex 3 SDK

It is relatively easy to use the free open-source Flex 3 SDK to compile an mxml document and create a swf file that can be run stand-alone in the Flash Player.It is more difficult to deploy that swf file on a server.

Compiling an mxml file from the command line

The main claim to fame for XML is that XML files are plain text files. An mxml file is an XML file. Therefore, you can create an mxml file containing mxmlcode, (such as that shown in Listing 1) , using any plain text editor.

(The code shown in Listing 1 is the same as the code used in the Flex application in the earlier lesson titled The Default Application Container - Flex 3 and Flex 4 .)

Flex application named test.mxml.

<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"backgroundColor="#FF0000" backgroundGradientColors="[#00FF00, #0000FF]" backgroundAlpha="1.0"></mx:Application>

A test program

Assume that you have created such a file named test.mxml and that you have stored the file in the following folder on a Windowssystem:

C:\jnk\1\test.mxml

Download the zip file containing the Flex 3 SDK (see Resources ) and extract the contents of the zip file into a folder of your choosing. That folder will then contain the following file:

...\bin\mxmlc.exe

Compile the test program

If you open a command-line window in the bin folder and execute the following command on the command line, the mxml file willbe compiled and a file named test.swf will be created in the same folder as the mxml file:

mxmlc c:\jnk\1\test.mxml

If you have a stand-alone Flash Player (version 9 or later) on your system, you can open the file named test.swf in that player.

Testing your installation

You should have no difficulty using this approach to modify the backgroundAlpha values in the mxml code shown in Listing 1 to produce swf files that produce the four gradient images shown in Figure 1 when run in astand-alone Flash Player version 9 or later. (Note that the four images shown in Figure 1 are actually screen shots of the swf files running in abrowser.)

Test program output for alpha values of 0.0, 0.33, 0.66, and 1.0.

Missing image.
Test program output for alpha values of 0.0, 0.33, 0.66, and 1.0.

Four runs with different alpha values

For this example, the mxml code shown in Listing 1 was modified, compiled, and run four times in succession by substituting four different values of backgroundAlpha into the code.

Four output images

The four images shown in Figure 1, going from left to right, top to bottom, represent alpha values of 0.0, 0.33, 0.66, and 1.0 respectively.

An alpha value of 0.0

For an alpha value of 0.0, the output color is pure red as shown by the top-left image in Figure 1. In this case, the gradient color scheme is totallytransparent.

An alpha value of 1.0

For an alpha value of 1.0, the output colors range from pure green at the top to pure blue at the bottom as shown in the bottom-right image in Figure 1. Inthis case, the gradient color scheme is totally opaque and the red background color doesn't show through at all.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Introduction to xml. OpenStax CNX. Dec 02, 2014 Download for free at https://legacy.cnx.org/content/col11207/1.18
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Introduction to xml' conversation and receive update notifications?

Ask