<< 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
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.
You can read more on the topic of required namespaces here .
Figure 1 shows the output from the Flex 3 program named Namespace01 that I explained in the earlier lesson on this topic.
Figure 2 shows the output from the Flex 4 program named Namespace02 that I will explain in this lesson.
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
Notification Switch
Would you like to follow the 'Introduction to xml' conversation and receive update notifications?