<< 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:

  • Students, faculty and staff of eligible educational institutions
  • Software developers who are affected by the current economic condition and are currently unemployed
  • Event attendees who receive a special promotional code at their event

Skeleton mxml code and namespaces

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.

Skeleton mxml code for a new 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.

Skeleton mxml code for a new 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>

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