Newest Articles

8 Ball Pool
Photo Reel
Image Color Tinting using Actionscript
3d Rotating Image Cube
Image Slider with Easing
Catapult Game


Popular Articles

True Fullscreen Flash Mode
8 Ball Pool
FLV Player
Image Slider
Mp3 Player with XML Playlist
Album Slide


Random Articles

Glowing Orb
Show the Current Frames Per Second
Alert Box
Photo Reel
Growing Tree using Recursion
Image Slider


Links

Foundation-Flash
Tutorial4Me
MickM
TutorialQuest
Tutorialsphere.com - Free Online Tutorials
Newgrounds
TWiT
Link to SwfSpot
Swf Spot



rss feed

Custom Right Click Menu

Custom Right Click Menu
AddThis Social Bookmark Button
Description: Change flash's default right-click menu using actionscript.
Author: John Bezanis
Added: January 21st 2007
Version: Flash 8
Total Views: 6205
Views in the Past 7 Days: 118


Changing the right click menu is simple and takes only a few lines of code.
actionsframe
Place the following code in the Actions tab on the main stage:
  1. var linkURL="http://www.bezzmedia.com";
  2. var linkText="Link Text";
  3. //Defines a new right-click menu
  4. var myMenu = new ContextMenu();
  5. //goToThisURL is a function that gets run whenever the link is clicked
  6. function goToThisURL(){
  7.   //_blank opens the link in a new window
  8.   getURL(linkURL, "_blank");
  9. }
  10. //Create a new item for the new menu.
  11. var copyright = new ContextMenuItem(linkText, goToThisURL);
  12. //Add the item to the new menu
  13. myMenu.customItems.push(copyright);
  14. //Hide flash's built in items (zoom in, zoom out, etc)
  15. myMenu.hideBuiltInItems();
  16. //Apply the new menu
  17. _root.menu = myMenu;
Additional items can be added to menu by adding in a few lines just before the last line.
  1. function someFunctionName(){
  2.   //_self opens the link in the same window
  3.   getURL(linkURL, "_self");
  4. }
  5. var menuItem = new ContextMenuItem("Some More Link Text", someFunctionName);
  6. //Add the item to the menu
  7. myMenu.customItems.push(menuItem);
Menu items can perform tasks other than redirecting the browser. Simply place the actionscript you'd like to run inside of the function and the code will execute when the menu item is clicked. The provided example has a function which draws a line at a random location.

Download Source File
Questions and Suggestions
I wants add Change size option in Right click menu of Flv Player. And in this option i wants add 680x540, 480x360, 320x240 options. How can i do this.
December 12th 2007 01:12AM   -   James
I'm no pro but i believe _global would hold the document's dimmentions. If you want to change the size of the player that is playing the video, that would be javascript DOM
March 22nd 2008 22:03PM   -   guy
yep, to change the size of your flash you need to create a javascript function that resizes your flash movie, and call that function inside the flash movie. google it, you'll might find something related
April 10th 2008 12:04PM   -   JJ
Could you not just create 3 webpages with different sized movies and open them up via the right click menu?
April 24th 2008 07:04AM   -   mark
Add a Question or Suggestion
name:
website (optional):
captcha type the characters into the box
message (5000 characters or less):