<< Chapter < Page | Chapter >> Page > |
The project that I explained in the earlier lesson was created using Flex Builder 3. The project that I willexplain in this lesson was created using Flash Builder 4.
Free for educational use
As of June 2010, Adobe provides free copies of Adobe Flash Builder 4 Standard to:
Skeleton mxml code for a new Flex 3 project
When you create a new Flex 3 project in Flex Builder 3 or Flash Builder 4, a skeleton of the required mxml file is created for you. Listing 1 shows thecontents of such a skeleton mxml file for a Flex 3 project.
<?xml version="1.0" encoding="utf-8"?><mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"layout="absolute"></mx:Application>
Created using Flex Builder 3
The skeleton code shown in Listing 1 was created using Flex Builder 3, but the skeleton code for a Flex 3 project is essentially the same regardless ofwhether it is created using Flex Builder 3 or Flash Builder 4. (Flash Builder 4 inserts a couple of relatively insignificant size attributes that are not inserted by FlexBuilder 3.)
The namespace (xmlns) attribute
In the earlier lesson, I explained the concept of the root element , and I explained that the term xmlns is the required name for a namespace attribute. (This is true for XML in general and not just for Flex mxml.) While it isn't necessary in general to include a namespace attribute in the root element, when a namespace attribute is included in the root element, it becomes the default namespace for the entire document.
Namespace is always required for a Flex project
Even though it isn't necessary to include a namespace attribute in the root element of a general XML document, it is always necessary to include the namespace attribute shown in Listing 1in the root element of the main mxml document for a Flex 3 project. That is why Flex Builder 3 includes it in the skeleton code for the project.
What does this mean?
The inclusion of the default namespace attribute shown in Listing 1 means that all elements with names that refer to componentsfrom the standard Flex 3 library of components must be prefixed with "mx:" .
Skeleton mxml code for a new Flex 4 project
As with a Flex 3 project, when you create a new Flex 4 project in Flash Builder 4, a skeleton of the mxml file is created for you. Listing 2 shows thecontents of such a skeleton mxml file for a Flex 4 project.
<?xml version="1.0" encoding="utf-8"?><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955"minHeight="600"><fx:Declarations><!-- Place non-visual elements (e.g., services,
value objects) here --></fx:Declarations></s:Application>
Notification Switch
Would you like to follow the 'Introduction to xml' conversation and receive update notifications?