User Guide
MenuBar component (Flash Professional only) 583
Usage 2: The following example adds an Edit menu with the menu items Undo, Redo, Cut, and
Copy, which are defined in the MenuDataProvider instance
myMenuDP:
var myMenuDP = new XML();
myMenuDP.addMenuItem({label:"Undo", instanceName:"undoInst"});
myMenuDP.addMenuItem({label:"Redo", instanceName:"redoInst"});
myMenuDP.addMenuItem({type:"separator"});
myMenuDP.addMenuItem({label:"Cut", instanceName:"cutInst"});
myMenuDP.addMenuItem({label:"Copy", instanceName:"copyInst"});
myMenuBar.addMenuAt(0,"Edit",myMenuDP);
MenuBar.dataProvider
Availability
Flash Player 6 (6.0 79.0).
Edition
Flash MX Professional 2004.
Usage
myMenuBar.dataProvider
Description
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.
Example
The following example imports an XML file and assigns it to the
MenuBar.dataProvider property:
var myMenuBarDP = new XML();
myMenuBarDP.load("http://myServer.myDomain.com/source.xml");
myMenuBarDP.onLoad = function(success){
if(success){
myMenuBar.dataProvider = myMenuBarDP;
} else {
trace("error loading XML file");
}
}