View comments | RSS feed

<mx:XMLList> tag implemented by the compiler


The <mx:XMLList> tag is a compile-time tag that generates an XMLList object from a text model that consists of valid XML nodes.

Unlike the XMLList class in ActionScript, this tag lets you use MXML binding expressions in the XML text to extract node contents from variable data. For example, you can bind a node's name attribute to a text input value, as in the following line:

<child name="{textInput1.text}"/>

MXML Syntax

You can place an <mx:XMLList> tag in a Flex application file or in an MXML component file. The <mx:XMLList> tag must have an id attribute value to be referenced by another component. The <mx:XMLList> tag does not need an id attribute value if the tag is a direct child of an <mx:dataProvider> tag. The <mx:XMLList> tag cannot be the root tag of an MXML component.

The <mx:XML> tag has the following syntax:

	<mx:XMLList
	   id="list ID">
	      model declaration
	</mx:XMLList>

The following example uses the tag to define a model for MenuBar control:

    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="#FFFFFF">
    
    	<mx:XMLList id="myMenuModel">
    		<menuitem label="MenuItem A" >
    			<menuitem label="SubMenuItem 1-A" />
    			<menuitem label="SubMenuItem 2-A" />
    		</menuitem>
    		<menuitem label="MenuItem B" />
    		<menuitem label="MenuItem C" type="check" />
    		<menuitem type="separator" />
    		<menuitem label="MenuItem D" >
    			<menuitem label="SubMenuItem 1-D" type="radio" groupName="one" />
    			<menuitem label="SubMenuItem 2-D" type="radio" groupName="one" />
    			<menuitem label="SubMenuItem 3-D" type="radio" groupName="one" />
    		</menuitem>
    	</mx:XMLList>
    
    
    	<mx:MenuBar id="myMenu" labelField="@label" showRoot="true">
    		<mx:dataProvider>
    			{myMenuModel}
    		</mx:dataProvider>
    	</mx:MenuBar>
    
    </mx:Application>



Comments


Finty said on Jan 22, 2008 at 9:06 AM :
Hi,
my query relates to the example code at the bottom of this page:
http://livedocs.adobe.com/flex/2/langref/mxml/xmlList.html

How can I get the following 3 nodes in an xml list to be picked up by an event handler for the itemClick event of the MenuBar?

<mx:XMLList id="myMenuModel">
<menuitem label="Open" data="open" />
<menuitem label="Save" data="save" />
<menuitem label="Close" data="close" />
</mx:XMLList>

I appear to need a single root node containing further nodes which are the nodes that can be picked up by the event handler ( I want these 3 nodes to sit at the root level of my application - this is possible using xmllist).

This is what my event handler looks like:

private function menuHandler(event:MenuEvent):void {
if(event.item.@data =="save"){
}else if(event.item.@data =="open"){
}else if(event.item.@data =="close"){ }
}

They only seem to register to be heard by the listener if I use this xmllist structure (not suitable for my application):

<mx:XMLList id="myMenuModel">
<menuitem label="File">
<menuitem label="Open" data="open" />
<menuitem label="Save" data="save" />
<menuitem label="Close" data="close" />
</menuitem>
</mx:XMLList>

I appreciate any feedback on this.

Thanks,
Fintan
(fboyle.com)
Jovin49 said on Jan 22, 2008 at 3:10 PM :
The documentation for using Menu-based controls has been enhanced for Flex 2.0.1, and also for Flex 3.

Here's a link to the Developer Guide section on Using Menu Based Controls for the Flex 3 Developer's Guide. I think this should answer your question.

http://livedocs.adobe.com/labs/flex3/html/help.html?content=menucontrols_4.html#423864

Vince Genovese
Flex Doc Team

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/2/langref/mxml/xmlList.html