<< Chapter < Page Chapter >> Page >

The project tree for the Flex 4 project named Namespace02 is shown in Figure 3.

Project tree for the project named namespace02.

Missing image.
Project tree for the project named Namespace02.

A comparable image for the Flex 3 project named Namespace01 was provided in the earlier lesson. If you compare the two,you will see that more information is displayed in the project tree for the Flex 4 project in Figure 3.

Major items of interest

For purposes of this lesson, we will be primarily interested in the following items showing in Figure 3. Those are the items that I had to create inorder to create the project.

  • The file named Namespace02.mxml
  • The folder named customComps
  • The file named Button.mxml
  • The file named Label.mxml

Two buttons, three labels, etc.

As I explained in the earlier lesson, the project named Namespace01 creates a GUI with two buttons and three labels in VBox containers with red and cyan backgrounds as shown in Figure 1.

All are mx components

Because that project was created exclusively using Flex 3, all of the components shown inFigure 1 are Flex 3 components. I will sometimes refer to them as "mx" components because of the name of the namespace attribute shown in Listing 1.

No VBox components in Namespace02

Because the Flex 4 program named Namespace02 was intended to replicate Namespace01 , it also contains two buttons and three labels. However, as you will see later, they are not in VBox containers because there is no VBox container in Flex 4. Instead, they are in containers named Group and VGroup .

All are Spark components

Because Namespace02 was created exclusively using Flex 4, all of the components are Flex 4 components. I will sometimes refer to them as "Spark" components on the basis of the last word in the value of the namespace attribute named "s" in Listing 2.

The names "mx" and "Spark" actually derive from ActionScript package names, but an explanation of that is beyond the scope of this lesson.

The main mxml file for Namespace01

Listing 3 shows the code in the main mxml file for the Flex 3 project named Namespace01 .

The main mxml file for namespace01.

<?xml version="1.0"?><!-- Namespace01Illustrates the use of namespaces to avoid name conflicts. --><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:MyComps="customComps.*"backgroundColor="#FFFF00"><!--Add a standard VBox container--><mx:VBox backgroundColor="#FF0000"><mx:Label text="Standard Label" color="#FFFF00"fontSize="12" fontWeight="bold"/><mx:Button label="Standard Button" /><MyComps:Label id="customLabel"/><MyComps:Button id="customButton"/></mx:VBox></mx:Application>

The Application element

I will explain mxml syntax in more detail in future lessons, so I'm not going to go into syntax issues at this point in time. Suffice it tosay that the Application element in Listing 3 represents the entire program. Thebehavior as well as the look and feel of the program is defined by the attributes and the content of the Application element. Everything in the program is part of the attributes or the contentof the Application element.

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