Menu.dataProvider

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX Professional 2004.

Usage

menuInstance.dataProvider

Description

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.

Example

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);