<< Chapter < Page Chapter >> Page >

More namespace attributes in the root element

If you compare Listing 2 with Listing 1, you will see that the namespace attributes in Listing 2 are different from those in Listing 1, and there aremore of them in Listing 2.

Listing 1 has only one namespace attribute while Listing 2 has three namespace attributes.

Mix or match Flex components

You can use Flash Builder 4 to create projects that

  • use Flex 3 exclusively
  • use Flex 4 exclusively
  • use a mixture of the two

Must specify compiler version for project

When you create a new project in Flash Builder 4, you must specify whether the project is to be compiled using the Flex 3 compiler or the Flex 4 compiler.

Different versions of the skeleton code

If you specify the Flex 3 compiler, the skeleton code will look like Listing 1 (with a couple of additional sizing attributes) . For that case, you must use Flex 3 components exclusively.

If you specify the Flex 4 compiler, the skeleton code will look like Listing 2. In that case, you can use Flex 3 components,Flex 4 components, or a mixture of the two.

What do these namespace attributes mean?

Building on what I explained earlier, the inclusion of the namespace attributes with the name "mx" in Listing 1 and Listing 2 means that all elements with names that refer to components from the Flex 3 library ofcomponents must be prefixed with "mx:" . (You will see examples of this in code fragments later in this lesson.)

The inclusion of the namespace attribute with the name "s" in Listing 2 means that all elements with names that refer to the new componentsfrom the Flex 4 library of components must be prefixed with "s:" . (You will also see examples of this in code fragments later in this lesson.)

Resolution of duplicate names

The Flex 3 library and the Flex 4 library contain many components with the same names, such as Label and Button . Therefore, the name of the component alone is not sufficient to identify which of twocomponents having the same name is to be used at a particular location in the program. The "mx:" prefix and the "s:" prefix are the mechanisms by which you identify the correct component to the compiler.

For those with knowledge of ActionScript or Java programming, this is analogous to using a package name to identify a class in those programminglanguages.

You can read more on the topic of required namespaces here .

The sample program named Namespace02

Figure 1 shows the output from the Flex 3 program named Namespace01 that I explained in the earlier lesson on this topic.

Output from namespace01.

Missing image.
Output from Namespace01.

Figure 2 shows the output from the Flex 4 program named Namespace02 that I will explain in this lesson.

Output from namespace02.

Missing image.
Output from Namespace02.

Mostly default look and feel

In both programs, the top portion of the output was purposely colored red and the bottom portion was purposely colored cyan. Otherwise, the colors, sizes,positions, and shapes of the components in both programs were allowed to take on defaultvalues.

The project tree for the project named Namespace02

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