Custom Flash Player Menus
7th December, 2008
I’ve posted a little tutorial here on making custom Flash context (right click) menus because when I learnt to do it (a long while back now though) there was very little out there describing how.
- First of all you need a function to take the menu action. It can do absolutely nothing, but it does need to exist for the menu item to work. For the example here though it will link to a website:
function menuClick() {
getURL("http://www.srjm.co.uk", _blank);
} - Next, declare the menu variable, it’s good practice (and incredibly helpful) to do it this way because then whenever you add to the menu you get the Code Hints.
var menu:ContextMenu = new ContextMenu(); - Finally, hide the existing menu (unless you wish to keep the play/rewind and other options) and add your own options instead, and apply it to the root context menu:
menu.hideBuiltInItems();
var menuItem1:ContextMenuItem = new ContextMenuItem("http://www.srjm.co.uk/", menuClick);
var menuItem2:ContextMenuItem = new ContextMenuItem("SRJM Design", menuClick, true, false);
menu.customItems.push(menuItem1);
menu.customItems.push(menuItem2);
_root.menu = menu;
The second ContextMenuItem has additional parameters to give it a horizontal line above and also make it unclickable.





Extra Stuff (Click to find out more!)