00:00
00:00
Newgrounds Background Image Theme

NobeastcanDefeatme 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!

As3: Context Menu (rightclickmenu)

2,426 Views | 10 Replies
New Topic Respond to this Topic

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?


lol

Response to As3: Context Menu (rightclickmenu) 2008-09-20 12:56:56


Oops, can a mod or sombody add a link at the top to http://www.newgrounds.com/bbs/topic/6958 18/9999
That is AS3 main. =)


lol

Response to As3: Context Menu (rightclickmenu) 2008-09-20 12:59:40


The actual ending code...

import flash.ui.ContextMenu;

stop();


var myMenu:ContextMenu = new ContextMenu();
myMenu.hideBuiltInItems();
this.contextMenu = myMenu;
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);

I missed out a

this.contextMenu = myMenu;

in the final bit of first post.

Sorry for triple post.


lol

Response to As3: Context Menu (rightclickmenu) 2008-09-20 14:24:40


You ask for help on how to make a Context Menu, a few people link you tutorials, then you make a tutorial on it based on what you learn, that's low. Plus, you have little knowledge of what you're doing because you have a stop(); action in there for no reason, along with "this." which isn't needed. That's low man, real low.


MY E-PENIS IS BIGGER THAN YOURS

8=================================>

...and this is my fag...

BBS Signature

Response to As3: Context Menu (rightclickmenu) 2008-09-20 14:33:08


I learnt (not from what i was told) but from researching...
I am just trying to hellp


lol

Response to As3: Context Menu (rightclickmenu) 2008-09-20 14:36:58


At 9/20/08 02:24 PM, El-Presidente wrote: Plus, you have little knowledge of what you're doing because you have a stop(); action in there for no reason.

Actually... Its part of a project i am working on and i just wrote this thread from that...


lol

Response to As3: Context Menu (rightclickmenu) 2008-09-20 14:53:10


Looks good. Probably use it. :)

Cheers.


BBS Signature

Response to As3: Context Menu (rightclickmenu) 2008-09-20 14:55:34


At 9/20/08 02:53 PM, zuperxtreme wrote: Looks good. Probably use it. :)

Cheers.

Your welcome ^^


lol

Response to As3: Context Menu (rightclickmenu) 2008-09-20 14:55:55


At 9/20/08 02:36 PM, xedon wrote: Actually... Its part of a project i am working on and i just wrote this thread from that...

What, did you change your mind after you made the post before? Plus, it's one of the worst explained tutorials that's been made in a while. You left out everything, like clicking the buttons and all that. You really should have thought this out BEFORE posting it.


MY E-PENIS IS BIGGER THAN YOURS

8=================================>

...and this is my fag...

BBS Signature

Response to As3: Context Menu (rightclickmenu) 2008-09-20 15:05:03


At 9/20/08 02:55 PM, El-Presidente wrote:
At 9/20/08 02:36 PM, xedon wrote: Actually... Its part of a project i am working on and i just wrote this thread from that...
What, did you change your mind after you made the post before? Plus, it's one of the worst explained tutorials that's been made in a while. You left out everything, like clicking the buttons and all that. You really should have thought this out BEFORE posting it.

I think its a decent tutorial, besides the fact that it obviously left out the clicking part.
It will let people know how to stop cheating.


BAH! 3.141592653589793238462643383279502 8841971693993751058209749445920...

Response to As3: Context Menu (rightclickmenu) 2008-09-20 15:22:10


Just thought that it will stop cheaters and you will be able to add your name there? (and maybe newgrounds)


lol