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


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


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.


Questions & Answers

Do somebody tell me a best nano engineering book for beginners?
s. Reply
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
what is the Synthesis, properties,and applications of carbon nano chemistry
Abhijith Reply
so some one know about replacing silicon atom with phosphorous in semiconductors device?
s. Reply
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
how to fabricate graphene ink ?
for screen printed electrodes ?
What is lattice structure?
s. Reply
of graphene you mean?
or in general
in general
Graphene has a hexagonal structure
On having this app for quite a bit time, Haven't realised there's a chat room in it.
what is biological synthesis of nanoparticles
Sanket Reply
what's the easiest and fastest way to the synthesize AgNP?
Damian Reply
types of nano material
abeetha Reply
I start with an easy one. carbon nanotubes woven into a long filament like a string
many many of nanotubes
what is the k.e before it land
what is the function of carbon nanotubes?
I'm interested in nanotube
what is nanomaterials​ and their applications of sensors.
Ramkumar Reply
what is nano technology
Sravani Reply
what is system testing?
preparation of nanomaterial
Victor Reply
Yes, Nanotechnology has a very fast field of applications and their is always something new to do with it...
Himanshu Reply
good afternoon madam
what is system testing
what is the application of nanotechnology?
In this morden time nanotechnology used in many field . 1-Electronics-manufacturad IC ,RAM,MRAM,solar panel etc 2-Helth and Medical-Nanomedicine,Drug Dilivery for cancer treatment etc 3- Atomobile -MEMS, Coating on car etc. and may other field for details you can check at Google
anybody can imagine what will be happen after 100 years from now in nano tech world
after 100 year this will be not nanotechnology maybe this technology name will be change . maybe aftet 100 year . we work on electron lable practically about its properties and behaviour by the different instruments
name doesn't matter , whatever it will be change... I'm taking about effect on circumstances of the microscopic world
how hard could it be to apply nanotechnology against viral infections such HIV or Ebola?
silver nanoparticles could handle the job?
not now but maybe in future only AgNP maybe any other nanomaterials
I'm interested in Nanotube
this technology will not going on for the long time , so I'm thinking about femtotechnology 10^-15
can nanotechnology change the direction of the face of the world
Prasenjit Reply
At high concentrations (>0.01 M), the relation between absorptivity coefficient and absorbance is no longer linear. This is due to the electrostatic interactions between the quantum dots in close proximity. If the concentration of the solution is high, another effect that is seen is the scattering of light from the large number of quantum dots. This assumption only works at low concentrations of the analyte. Presence of stray light.
Ali Reply
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Got questions? Join the online conversation and get instant answers!
QuizOver.com Reply

Get the best Algebra and trigonometry course in your pocket!

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?