ActionScript 2.0 Components Language Reference |
|
|
|
| MenuBar component > MenuBar.dataProvider | |||
Flash Player 6 (6.0.79.0).
Flash MX Professional 2004.
menuBarInstance.dataProvider
Property; the data model for items in a MenuBar component.
MenuBar.dataProvider is an XML node object. Setting this property replaces the existing data model of the MenuBar component. Whatever child nodes the data provider might have are used as the items for the menu bar itself; any subnodes of these child nodes are used as the items for their respective menus.
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 MenuBar component. |
The following example loads an XML menu file from a web page and uses the onLoad event handler to assign it to the dataProvider property of the MenuBar instance my_mb.
Drag an instance of the MenuBar component onto the Stage, and enter the instance name my_mb in the Property inspector. Add the following code to Frame 1 of the timeline:
/**
Requires:
- MenuBar component on Stage (instance name: my_mb)
*/
var my_mb:mx.controls.MenuBar;
var myDP_xml:XML = new XML();
myDP_xml.ignoreWhite = true;
myDP_xml.onLoad = function(success:Boolean) {
if (success) {
my_mb.dataProvider = myDP_xml.firstChild;
} else {
trace("error loading XML file");
}
};
myDP_xml.load("http://www.flash-mx.com/mm/xml/menubar.xml");
|
|
|
|