00:00
00:00
Newgrounds Background Image Theme

studda614 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS: Swf right-click Menu

14,798 Views | 57 Replies
New Topic Respond to this Topic

AS: Swf right-click Menu 2005-07-01 10:28:27


AS: Main

Changing the swf right-click menu

I need to begin by saying that full customisation of the swf right-click menu is only available in Flash MX 2004 and higher. If you're stuck with an earlier version, the best you can do is disable the menu by using

FSCommand("showMenu", false);

=========================================================

OK. So if you ARE using MX 2004, you can basically change the swf context menu to suit your needs.
Lets start off by creating a new menu, and hiding the default Macromedia entries. This should be on the first frame of your Flash:

var myMenu=new ContextMenu();
myMenu.hideBuiltInItems();

Next, let's create a menu item that will open Newgrounds in a browser, and add the text 'Visit Newgrounds' to the menu

function itemHandler1(obj, item){getURL("http://newgrounds.com");}
item1=new ContextMenuItem("Visit Newgrounds", itemHandler1);
myMenu.customItems.push(item1);

This code could alternatively be written like this:

myMenu.customItems.push(new ContextMenuItem("Visit Newgrounds", itemHandler1));
function itemHandler1(obj, item){getURL("http://newgrounds.com");}

Finally, we replace the default menu with myMenu

_root.menu=myMenu;

That's it. You have a new context menu.

=========================================================

Here's an example that will show 'Stop' and 'Play' on the menu, greying one each one out when it's pressed.

var myMenu=new ContextMenu();
myMenu.hideBuiltInItems();
myMenu.customItems.push(new ContextMenuItem("Stop!", itemHandler0));
myMenu.customItems.push(new ContextMenuItem("Play!", itemHandler1));
myMenu.customItems[1].separatorBefore = true; //this will add a separator between the two items
function itemHandler0(obj, item){
_root.stop();
myMenu.customItems[0].enabled=false;
myMenu.customItems[1].enabled=true;
}
function itemHandler1(obj, item){
_root.play();
myMenu.customItems[0].enabled=true;
myMenu.customItems[1].enabled=false;
}
_root.menu=myMenu;

You can basically create as many itemHandler functions as you want, and push them into the menu array. In fact, it's entirely possible to adapt this code and run it on button/MC rollovers & rollouts, to allow different context menus for different symbols in your movie/game

More information

http://www.actionscript.org/fo...3?t=47891&page=2&pp=15
http://planetbob.net/ftd/contextmenu/contextmenu.htm
http://www.actionscript.org/tutorials/intermediate/context_menu/index.shtml


- - Flash - Music - Images - -

BBS Signature

Response to AS: Swf right-click Menu 2005-07-01 10:32:16


Great Denvish! I bookmarked this for the future!

Response to AS: Swf right-click Menu 2005-07-01 10:44:54


very good denvish, just for further reference use Stage.showMenu=false; instead of FScommand, it's newer and "faster"

Response to AS: Swf right-click Menu 2005-07-01 10:58:08


I agree.

Response to AS: Swf right-click Menu 2005-07-01 10:59:57


thanks for that!!! :D

Response to AS: Swf right-click Menu 2005-07-01 11:03:41


At 7/1/05 10:44 AM, Inglor wrote: very good denvish, just for further reference use Stage.showMenu=false; instead of FScommand, it's newer and "faster"

Oops. I knew that, I just wasn't paying attention when I copy/pasted that code.


- - Flash - Music - Images - -

BBS Signature

Response to AS: Swf right-click Menu 2005-07-01 11:31:19


AWWW. you copied and pasted! :P Just kidding.

Thanks for this tutorial. I found it VERY useful. *bookmarks*

You should've also included how to make the screen fullsize, through the right click menu.

I think it's like FSCommand (full, true) or something. I'm not sure.


the events are merely fictional, written, directed, and acted out by all who create them

BBS Signature

Response to AS: Swf right-click Menu 2005-07-06 14:57:23


You can also change it to this to make your own custom "quality" buttons:

function itemHandler1(obj, item){_quality = "low";;}
item1=new ContextMenuItem("Low quality", itemHandler1);
myMenu.customItems.push(item1);

You can change "low" to other things like "best" (yes, a secret quality), medium or high.


#include <stdio.h>

char*p="#include <stdio.h>%cchar*p=%c%s%c;%cmain() {printf(p,10,34,p,34,10);}";

main() {printf(p,10,34,p,34,10);}

BBS Signature

Response to AS: Swf right-click Menu 2005-07-06 14:59:38


Wow this is really awesome, people can learn AS well just from reading your guides! Good jobs Denvish!

P.S. Cool sig! :D


BBS Signature

Response to AS: Swf right-click Menu 2005-07-06 18:25:47


I have a question.

How do you make a thing that goes out? Like in the default menu when you click "Quality" a little mini menu comes out and you can select the quality.


#include <stdio.h>

char*p="#include <stdio.h>%cchar*p=%c%s%c;%cmain() {printf(p,10,34,p,34,10);}";

main() {printf(p,10,34,p,34,10);}

BBS Signature

Response to AS: Swf right-click Menu 2005-07-06 18:38:21


At 7/6/05 06:25 PM, icycomputer wrote: I have a question.

How do you make a thing that goes out? Like in the default menu when you click "Quality" a little mini menu comes out and you can select the quality.

Good question. Answer: I don't know.


- - Flash - Music - Images - -

BBS Signature

Response to AS: Swf right-click Menu 2005-07-06 18:59:47


At 7/6/05 06:38 PM, Denvish wrote:
At 7/6/05 06:25 PM, icycomputer wrote: I have a question.

How do you make a thing that goes out? Like in the default menu when you click "Quality" a little mini menu comes out and you can select the quality.
Good question. Answer: I don't know.

Damn.


#include <stdio.h>

char*p="#include <stdio.h>%cchar*p=%c%s%c;%cmain() {printf(p,10,34,p,34,10);}";

main() {printf(p,10,34,p,34,10);}

BBS Signature

Response to AS: Swf right-click Menu 2005-07-17 16:16:25


well here is what i would, do i dont know for the little mini menu, but to have just the quality.

Code:

function itemHandler5(obj, item){_quality = "high";}
function itemHandler6(obj, item){_quality = "medium";}
function itemHandler7(obj, item){_quality = "low";}

root_cm = new ContextMenu();
root_cm.hideBuiltInItems();

eee_cmi = new ContextMenuItem("High Quality", itemHandler5);
fff_cmi = new ContextMenuItem("Mid Quality", itemHandler6);
ggg_cmi = new ContextMenuItem("Low Quality", itemHandler7);

ccc_cmi.separatorBefore = true;
eee_cmi.separatorBefore = true;

root_cm.customItems.push(aaa_cmi, bbb_cmi, ccc_cmi, ddd_cmi, eee_cmi, fff_cmi, ggg_cmi);
_root.menu = root_cm;

Response to AS: Swf right-click Menu 2005-07-24 06:52:56


At 7/1/05 10:28 AM, Denvish wrote: You can basically create as many itemHandler functions as you want

Not according to the Actionscript Dictionary, you can't. 15 appears to be the limit, although I never tested :P

At 7/1/05 11:31 AM, Starogre wrote: I think it's like FSCommand (full, true) or something. I'm not sure.

fscommand("fullscreen", true) is correct.

At 7/6/05 06:25 PM, icycomputer wrote: How do you make a thing that goes out? Like in the default menu when you click "Quality" a little mini menu comes out and you can select the quality.

It's not in the properties or methods of ContextMenuItem, so I don't think it's possible. Too bad, I could've used it too.

Oh, and I just thought I'd add one point to the tutorial:
Custom Items in a context menu can't contain the words "Macromedia", "Flash Player", or "Settings". To prevent trickery, I guess.


BBS Signature

Response to AS: Swf right-click Menu 2005-07-24 08:19:25


At 7/24/05 06:52 AM, Rantzien wrote: Not according to the Actionscript Dictionary, you can't. 15 appears to be the limit, although I never tested :P

there are ways around that

At 7/6/05 06:25 PM, icycomputer wrote:
It's not in the properties or methods of ContextMenuItem, so I don't think it's possible. Too bad, I could've used it too.

sure it's possible, you make a movieclip that looks like the menu, and clicking the menu item pops it.

Custom Items in a context menu can't contain the words "Macromedia", "Flash Player", or "Settings". To prevent trickery, I guess.

actually, that's new to me, tnx :)

Response to AS: Swf right-click Menu 2005-07-24 08:28:39


At 7/24/05 08:19 AM, Inglor wrote: sure it's possible, you make a movieclip that looks like the menu, and clicking the menu item pops it.

But that would close the regular menu right? What I meant was that I don't think it's possible to do it so that it looks and works like the usual. But you're right of course, there are ways around most things

actually, that's new to me, tnx :)

No prob :P


BBS Signature

Response to AS: Swf right-click Menu 2005-07-29 04:31:12


not entirely. there will always be 2 items in the menu. i wish you could though. then i could set right click to some action

Response to AS: Swf right-click Menu 2005-08-02 15:09:07


Thanx, it helps.

Response to AS: Swf right-click Menu 2005-09-08 13:47:14


Hello boys and girls. I just came to think of this, a little tool I made quite a while ago. Note that you have to be very lazy or a copy-and-paster to have any use of it.

Good day, or in Swedish:
"Jamen då får du väl ha det så trevligt då, och så ses vi imorgon eller någon annan dag. Hej då, Betty!"


BBS Signature

Response to AS: Swf right-click Menu 2005-09-08 13:54:49


At 9/8/05 01:47 PM, Rantzien wrote: Hello boys and girls. I just came to think of this, a little tool I made quite a while ago. Note that you have to be very lazy or a copy-and-paster to have any use of it.

I saw that on the portal, I gave it a 1. It didn't deserve to stay in the portal but it can be useful.


Sup, bitches :)

BBS Signature

Response to AS: Swf right-click Menu 2005-09-08 14:01:02


At 9/8/05 01:54 PM, -liam- wrote: I saw that on the portal, I gave it a 1. It didn't deserve to stay in the portal but it can be useful.

You are now my enemy.

No, just kidding. I know it didn't really belong in the portal, I would've voted low too :D


BBS Signature

Response to AS: Swf right-click Menu 2005-09-12 16:14:46


i used all the scripts said here and the menu looks like this...

Visit Newgrounds
-------------------------
Play!
Stop!
High Quality
Medium Quality
Low Quality
-------------------------
Settings
-------------------------
Debugger

is there any way i can insert a horizontal rule (the ------------...) in between "high Quality" and "stop!"?


[RE Club]:[SSB Crew]:[Free Hentai Exchange Club]

Want animated Signature Pics back? Copy this Sig Pic as protest!

BBS Signature

Response to AS: Swf right-click Menu 2005-09-12 16:20:23


At 9/12/05 04:14 PM, DevilsSin666X wrote: is there any way i can insert a horizontal rule (the ------------...) in between "high Quality" and "stop!"?

This is the appropriate code line:

myMenu.customItems[1].separatorBefore = true; //this will add a separator between the two items

Just copy/paste that line, and change the [1] as appropriate.


- - Flash - Music - Images - -

BBS Signature

Response to AS: Swf right-click Menu 2005-09-12 16:42:45


At 9/12/05 04:20 PM, Denvish wrote: This is the appropriate code line:

thanks.


[RE Club]:[SSB Crew]:[Free Hentai Exchange Club]

Want animated Signature Pics back? Copy this Sig Pic as protest!

BBS Signature

Response to AS: Swf right-click Menu 2005-09-12 16:47:33


At 9/12/05 04:42 PM, DevilsSin666X wrote:
At 9/12/05 04:20 PM, Denvish wrote: This is the appropriate code line:
thanks.

I can't believe I used 'appropriate' twice in the same post. Quelle fromage...


- - Flash - Music - Images - -

BBS Signature

Response to AS: Swf right-click Menu 2005-10-04 00:29:12


id just like to say

FINALLY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!111111
Ive been looking for this for a while and couldnt find it. Thx Denvish!

Response to AS: Swf right-click Menu 2005-10-21 10:46:32


WHY DOES NOONE EVER EXPLAIN?!??!
this really doesn't help me, though i thought i finally found something...dissapointing =(

Response to AS: Swf right-click Menu 2005-10-21 14:10:14


At 10/21/05 10:46 AM, -Rhinan- wrote: WHY DOES NOONE EVER EXPLAIN?!??!
this really doesn't help me, though i thought i finally found something...dissapointing =(

How come everybody else in this thread is able to understand perfectly what I wrote, AND make it work, and you can't?

It's not a problem with the tutorial, it's a problem with your brain.


- - Flash - Music - Images - -

BBS Signature

Response to AS: Swf right-click Menu 2005-10-29 17:47:47


var myMenu = new ContextMenu();
myMenu.hideBuiltInItems();
function itemHandler1(obj, item) {
_root._quality = "high";
}
item1 = new ContextMenuItem("High Quality", itemHandler1);
myMenu.customItems.push(item1);
function itemHandler2(obj, item) {
_root._quality = "medium";
}
item2 = new ContextMenuItem("Medium Quality", itemHandler2);
myMenu.customItems.push(item2);
function itemHandler3(obj, item) {
_root._quality = "low";
}
item3 = new ContextMenuItem("Low Quality", itemHandler3);
myMenu.customItems.push(item3);
function itemHandler4(obj, item) {
stopAllSounds();
_root.music.attachSound("song1");
_root.music.start(0, 10000);
}
item4 = new ContextMenuItem("Creepy Music", itemHandler4, true);
myMenu.customItems.push(item4);
function itemHandler5(obj, item) {
stopAllSounds();
_root.music.attachSound("song2");
_root.music.start(0, 10000);
}
item5 = new ContextMenuItem("Spooky Music", itemHandler5);
myMenu.customItems.push(item5);
function itemHandler6(obj, item) {
stopAllSounds();
_root.music.attachSound("song3");
_root.music.start(0, 10000);
}
item6 = new ContextMenuItem("Crazy Scary Music", itemHandler6);
myMenu.customItems.push(item6);
function itemHandler7(obj, item) {
stopAllSounds();
_root.music.attachSound("song4");
_root.music.start(0, 10000);
}
item7 = new ContextMenuItem("Weird Music", itemHandler7);
myMenu.customItems.push(item7);
function itemHandler8(obj, item) {
stopAllSounds();
}
item8 = new ContextMenuItem("No Music", itemHandler8);
myMenu.customItems.push(item8);
_root.menu = myMenu;


Sup, bitches :)

BBS Signature

Response to AS: Swf right-click Menu 2005-12-11 20:43:19


Thanks Denvish!

For a while I just copied and pasted the codes from this thread,until I saw how easy it was myself...coolio.You learned I something old yesterday ;)

Translation: You taught me somethign new today.

wat