Macromedia flex 2 Manuale

Pagina di 254
About MXML components
79
The main application, or any other MXML component file, references the StateComboBox 
component, as the following example shows:
<?xml version="1.0"?>
<!-- mxml/MyApplication.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    xmlns:MyComp="*">
    <MyComp:StateComboBox/>
</mx:Application>
In this example, the main application file includes a new namespace definition of 
xmlns:MyComp="*"
 as part of the 
<mx:Application>
 tag. This namespace definition 
specifies the location of the MXML component. In this case, it specifies that the component 
is in the same directory as the main application file or, if you are using Flex Data Services, in 
the WEB-INF/flex/user-classes directory. 
As a best practice, store your components in a subdirectory. For example, you can write this 
file to the myComponents directory, a subdirectory of your main application directory. For 
more information on the namespace, see Chapter 2, “Developing Applications in MXML,” in 
Flex 2 Developer’s Guide.