AS3 Context Menu
What You Will Learn
How to make and expand a right click menu for AS3.
The Good Part's
import flash.ui.ContextMenu;
Here is the basic context package which allows us too do all of this "snazzy" stuff.
var myMenu:ContextMenu = new ContextMenu();
Set's a variable called myMenu, turns it into a ContextMenu and then makes it a new one (so its not trying to refer to another ConText Menu.)
myMenu.hideBuiltInItems();
Declares the menu we just made and then hides the preset items (Things like play, stop, forward, back, rewind ETC). This stops some cheating.
var ourText1:ContextMenuItem = new ContextMenuItem("Example Text");
var ourText2:ContextMenuItem = new ContextMenuItem("Example Text 2");
var ourText3:ContextMenuItem = new ContextMenuItem("Example Text 3");
Makes a variable, assigns it a name (it can be almost anything), makes it a new context item and calls it whatever. In our case its Example Text , Example Text 2 and Example Text 3.
ourText3.separatorBefore = true;
Declares the item, and then assigns a seperator before it. (A seperator is a line that is usually above setting's.)
myMenu.customItems.push(ourText1, ourText2, ourText3);
Declares which menu we want, gets the items and then adds them to the list. They are seperated my comma's.
import flash.ui.ContextMenu;
var myMenu:ContextMenu = new ContextMenu();
myMenu.hideBuiltInItems();
var ourText1:ContextMenuItem = new ContextMenuItem("Example Text");
var ourText2:ContextMenuItem = new ContextMenuItem("Example Text 2");
var ourText3:ContextMenuItem = new ContextMenuItem("Example Text 3");
ourText3.separatorBefore = true;
myMenu.customItems.push(ourText1, ourText2, ourText3);
Sorry, atm i dont know an SWF uploading site so i cannot upload my demo.
Thanks.
NOTE: This is my first tutorial, feedback?