MACROMEDIA FLASH 8-COMPONENTS LANGUAGE Reference page 899

Components language reference
Table of Contents

Advertisement

To use a well-formed XML string to create and populate a menu:
1.
Select File > New and create a Flash document.
2.
Drag the Menu component from the Components panel to the library.
Menus are created dynamically through ActionScript.
3.
In the Actions panel, add the following code to the first frame to create a menu and add
some items:
/**
Requires:
- Menu component in library
*/
import mx.controls.Menu;
// Create an XML object to act as a factory.
var my_xml:XML = new XML();
// The item created next does not appear in the menu.
// The createMenu() method call (below) expects to
// receive a root element whose children will become
// the items. This is just a simple way to create that
// root element and give it a convenient name.
var theMenuElement_obj:Object = my_xml.addMenuItem("XXXXX");
// Add the menu items.
theMenuElement_obj.addMenuItem({label:"Undo"});
theMenuElement_obj.addMenuItem({type:"separator"});
theMenuElement_obj.addMenuItem({label:"Cut"});
theMenuElement_obj.addMenuItem({label:"Copy"});
theMenuElement_obj.addMenuItem({label:"Paste"});
theMenuElement_obj.addMenuItem({label:"Clear", enabled:"false"});
theMenuElement_obj.addMenuItem({type:"separator"});
theMenuElement_obj.addMenuItem({label:"Select All"});
// Create the Menu object.
var my_menu:Menu = Menu.createMenu(this, theMenuElement_obj);
// Show and position the menus.
my_menu.show(100, 20);
4.
Select Control > Test Movie.
Creating an application with the Menu component (Flash Professional only)
895

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?

This manual is also suitable for:

Flash 8

Table of Contents