<< Chapter < Page Chapter >> Page >

Lots of comments

As you can see, I included lots of comments in Listing 4 in an attempt to make it as self-explanatory as possible.

In this lesson, I will concentrate on the differences between this Flex 4 project and the Flex 3 project named Namespace01 that arise from creating the two projects using different versions of Flex.

Order of attributes is not important

Let me begin by explaining that in XML, the order in which you write the attributesfor an element doesn't matter so long as they are all there with the correct syntax, the correct names, and the correct values.

More and different namespace attributes

As I explained earlier, a Flex 4 project often has three required namespace attributes and almost always has two. (Because I didn't use any mx components in this program, I could have removed the namespace attribute named mx from Listing 4.)

Other than the namespace attributes, the application element in Listing 4 has the same attribute names and values as the application element in Listing 3.

No VBox element in Namespace02

The next thing to notice is that there is no mx:VBox element in Listing 4. Instead, there is an s:Group element (a Flex 4 Spark component) that replaces the mx:VBox element and serves as a container for the labels and the buttons.

No backgroundColor attribute

The s:Group element has two positioning attributes that cause it to appear in the center of the Flash Playerwindow, but it does not have an attribute named backgroundColor . Like many of the Spark components, and unlike many of the mx components, the s:Group element does not have built-in attributes that are used to control its appearance. Instead, other ways must be found to control theappearance of many Spark components.

A red rectangle

In this case, Listing 4 causes the s:Group element to appear to have a red background by causing it to contain a red rectangle of exactly the right dimensions to completely fillthe s:Group element. This produces the red background color in the upper portion of Figure 2.

As with Figure 1, the lower portion of Figure 2 also has a red background color, but it is covered by another smaller rectangle with an opaque cyan color.

Add an s:VGroup container

Then Listing 4 adds a Spark s:VGroup container to serve essentially the same purpose as the mx:VBox container in Listing 3 (except that it doesn't control the red background color) . The following elements are added tothe s:VGroup element in Listing 4 In a manner very similar to Listing 3:

  • s:Label
  • s:Button
  • MyComps:Label
  • MyComps:Button

The first two elements in the above list are Spark elements having similar characteristics to the mx elements having the same names.

The last two elements in the above list are custom components having similar characteristicsto the custom components having the same names in the earlier program.

Contents of the file named Label.mxml

The contents of the custom component file named Label.mxml are shown in Listing 5.

Contents of the file named label.mxml.

<?xml version="1.0" encoding="utf-8"?><!--Create a custom label by putting a Spark Label in a Spark Group--><s:Group xmlns:MyComps="customComps.*" xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"><s:Label text="Custom Label"color="#FFFF00" fontSize="12"fontWeight="bold"/></s:Group>

Contents of the file named Button.mxml

The contents of the custom component file named Button.mxml are shown in Listing 6.

Contents of the file named button.mxml.

<?xml version="1.0" encoding="utf-8"?><!--Create a custom component by putting a Spark Label and a Spark Button in a Spark VGroup inside of a SparkGroup with a Cyan background color.--><s:Group xmlns:MyComps="customComps.*" xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"><!--Fill the entire group with a cyan rectangle--><s:Rect width="100%" height="100%"><s:fill><s:SolidColor color="0x00FFFF" /></s:fill></s:Rect><!--Put a Spark VGroup in the Group and put a Spark Label and a Spark Button in the VGroup--><s:VGroup><s:Label text="Custom Component."color="#000000" fontSize="12" fontWeight="bold"/><s:Button label="Button"/></s:VGroup></s:Group>

No further explanation needed

Assuming that you understand the contents of the files named Label.mxml and Button.mxml in the Flex 3 program in the earlier lesson, and assuming that you understood the explanation of thedifferences between the two main mxml files given above, the comments in Listing 5 and Listing 6 should serve as a sufficient explanation of the code in Listing5 and Listing 6.

Run the program

I encourage you to run this program from the web. Then copy the code from Listing 4 through Listing 6. Use that code tocreate your own projects. Compile and run the projects. Experiment with the code, making changes, and observing the results of your changes. Makecertain that you can explain why your changes behave as they do.

Resources

I will publish a list containing links to Flex resources as a separate document. Search for Flex Resources in theConnexions search box.

Miscellaneous

This section contains a variety of miscellaneous materials.

Housekeeping material
  • Module name: XML - Namespaces - Flex 4
  • Files:
    • Flex0086a\Connexions\FlexXhtml0086a.htm
PDF disclaimer: Although the Connexions site makes it possible for you to download a PDF file for thismodule at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should beaware that some of the HTML elements in this module may not translate well into PDF.

-end-

Questions & Answers

how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
what is inflammation
Shelly Reply
part of a tissue or an organ being wounded or bruised.
Wilfred
what term is used to name and classify microorganisms?
Micheal Reply
Binomial nomenclature
adeolu
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

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