UNCOMMENTED
var shape1:Shape = new Shape();
shape1.graphics.beginFill(0xB4A4F4);
shape1.graphics.drawRect(0,0,40,40);
shape1.graphics.endFill();
var mc1:MovieClip = new MovieClip();
mc1.addChild(shape1);
mc1.x = 40; mc1.y = 40;
addChild(mc1);
var shape2:Shape = new Shape();
shape2.graphics.beginFill(0xBADFB9);
shape2.graphics.drawRect(0,0,40,40);
shape2.graphics.endFill();
var mc2:MovieClip = new MovieClip();
mc2.addChild(shape2);
mc2.x = mc1.x; mc2.y = mc1.y * 3;
addChild(mc2);
var stringForLink:String;
var dateNow:Date = new Date();
var preString:String = “Context Menu for: “;
var postString:String = “.”;
var myContextMenu = new ContextMenu();
myContextMenu.hideBuiltInItems();
var copyrightNotice:ContextMenuItem = new ContextMenuItem(“© “ + dateNow.fullYear + ” justthecodeplease.com”);
var catNotice:ContextMenuItem = new ContextMenuItem(“Developed by Coding Cat”, true, false, true);
var closeMenu:ContextMenuItem = new ContextMenuItem(“Close This Menu”, false, true, true);
var mySiteLink:ContextMenuItem = new ContextMenuItem(stringForLink);
copyrightNotice.separatorBefore = true;
copyrightNotice.enabled = false;
stringForLink = preString + ” Square One” + postString;
myContextMenu = new ContextMenu();
myContextMenu.hideBuiltInItems();
mySiteLink = new ContextMenuItem(stringForLink);
myContextMenu.customItems.push(mySiteLink, closeMenu, catNotice, copyrightNotice);
mySiteLink.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,function() { navigateToURL(new URLRequest(“http://www.justthecodeplease.com“), “blank”);});
mc1.contextMenu = myContextMenu;
stringForLink = preString + ” Square Two” + postString;
myContextMenu = new ContextMenu();
myContextMenu.hideBuiltInItems();
mySiteLink = new ContextMenuItem(stringForLink);
myContextMenu.customItems.push(mySiteLink, closeMenu, catNotice, copyrightNotice);
mySiteLink.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,function() { navigateToURL(new URLRequest(“http://www.justthecodeplease.com“), “blank”);});
mc2.contextMenu = myContextMenu;
stop();
COMMENTED
/* A Context Menu is what you see when you right-click
on a Flash presentation. This menu can be used to provide
information to the user, and as links to other URLs or files.
This script adds context menus to two objects on the stage.
*/
// dynamically adds two rectangles to stage
var shape1:Shape = new Shape();
shape1.graphics.beginFill(0xB4A4F4);
shape1.graphics.drawRect(0,0,40,40);
shape1.graphics.endFill();
var mc1:MovieClip = new MovieClip();
mc1.addChild(shape1);
mc1.x = 40; mc1.y = 40;
addChild(mc1);
var shape2:Shape = new Shape();
shape2.graphics.beginFill(0xBADFB9);
shape2.graphics.drawRect(0,0,40,40);
shape2.graphics.endFill();
var mc2:MovieClip = new MovieClip();
mc2.addChild(shape2);
mc2.x = mc1.x; mc2.y = mc1.y * 3;
addChild(mc2);
/* instantiates strings to be used in context menu.
stringForLink is a string of other concatenated strings
and will be used as a URL link under mySiteLink below */
var stringForLink:String;
// dateNow gets the current date
var dateNow:Date = new Date();
// a string to be used in the stringForLink string
var preString:String = “Context Menu for: “;
// another string to be used in the stringForLink string
var postString:String = “.”;
// instantiates your context menu, which will replace the default context menu
var myContextMenu = new ContextMenu();
// makes sure default menu items are hidden (optional)
myContextMenu.hideBuiltInItems();
/* instantiates, but does not display, the menu items
(does not establish the order in which the menu items appear) */
var copyrightNotice:ContextMenuItem = new ContextMenuItem(“© “ + dateNow.fullYear + ” justthecodeplease.com”);
/* four format options in parenthesis (your string, insert separator (ruled line) above Boolean,
enable/disable clickable Boolean, visible/invisible Boolean */
var catNotice:ContextMenuItem = new ContextMenuItem(“Developed by Coding Cat”, true, false, true);
var closeMenu:ContextMenuItem = new ContextMenuItem(“Close This Menu”, false, true, true);
// no format options added to next item (defaults to no-separator, clickable and visible)
var mySiteLink:ContextMenuItem = new ContextMenuItem(stringForLink);
/* another method for adding a separator (ruled line) above a menu item.
one default separator will appear and separate your last item from
the default items below it, which can’t be suppressed */
copyrightNotice.separatorBefore = true;
// another method for disabling menu items so they’re not clickable
copyrightNotice.enabled = false;
/* populates the stringForLink string variable with 3 concatenated strings,
one which is ” Square One” to identify the object it’s activated with */
stringForLink = preString + ” Square One” + postString;
// necessary to add a new context menu with it’s own features (strings, formatting, links)
myContextMenu = new ContextMenu();
myContextMenu.hideBuiltInItems();
mySiteLink = new ContextMenuItem(stringForLink);
// this adds your strings to the context menu in the order shown in the parenthesis
myContextMenu.customItems.push(mySiteLink, closeMenu, catNotice, copyrightNotice);
// makes the mySiteLink string link to an URL (or to a file)
mySiteLink.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,function() { navigateToURL(new URLRequest(“http://www.justthecodeplease.com“), “blank”);});
/* ties this context menu to the mc1 object.
for context menu to appear from anywhere the stage is clicked, use: this.contextMenu = myContextMenu; */
mc1.contextMenu = myContextMenu;
// another context menu for Square Two:
stringForLink = preString + ” Square Two” + postString;
myContextMenu = new ContextMenu();
myContextMenu.hideBuiltInItems();
mySiteLink = new ContextMenuItem(stringForLink);
myContextMenu.customItems.push(mySiteLink, closeMenu, catNotice, copyrightNotice);
mySiteLink.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,function() { navigateToURL(new URLRequest(“http://www.justthecodeplease.com“), “blank”);});
mc2.contextMenu = myContextMenu;
stop();
// Note: if you get a 1093: Syntax error, please retype all quotation marks in your editor