ActionScript 2.0 Components Language Reference |
|
|
|
| Menu component > Menu.dataProvider | |||
Flash Player 6 (6.0.79.0).
Flash MX Professional 2004.
menuInstance.dataProvider
Property; the data source for items in a Menu component.
Menu.dataProvider is an XML node object. Setting this property replaces the existing data source of the menu.
The default value is undefined.
|
NOTE |
All XML or XMLNode instances are automatically given the methods and properties of the MenuDataProvider class when they are used with the Menu component. |
The following example creates a menu (my_menu), loads menu items from a web page into an XML object, and then populates the menu with menu items by assigning child nodes of the XML object to the dataProvider property of the menu (my_menu.dataProvider).
You first drag a Menu component to the library and then add the following code to Frame 1:
/**
Requires:
- Menu component in library
*/
import mx.controls.Menu;
// Create the Menu object.
var my_menu:Menu = Menu.createMenu();
var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success:Boolean){
if (success) {
my_menu.dataProvider = my_xml.firstChild;
}
}
my_xml.load("http://www.flash-mx.com/mm/xml/menu.xml");
// Show and position the menus.
my_menu.show(100, 20);
|
|
|
|