Forum Topic: As3: Context Menu (rightclickmenu)

(448 views • 10 replies)

This topic is 1 page long.

<< < > >>
Elated

xedon

Reply To Post Reply & Quote

Posted at: 9/20/08 12:53 PM

xedon DARK LEVEL 08

Sign-Up: 09/06/07

Posts: 243

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


None

xedon

Reply To Post Reply & Quote

Posted at: 9/20/08 12:56 PM

xedon DARK LEVEL 08

Sign-Up: 09/06/07

Posts: 243

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


None

xedon

Reply To Post Reply & Quote

Posted at: 9/20/08 12:59 PM

xedon DARK LEVEL 08

Sign-Up: 09/06/07

Posts: 243

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


None

El-Presidente

Reply To Post Reply & Quote

Posted at: 9/20/08 02:24 PM

El-Presidente LIGHT LEVEL 27

Sign-Up: 06/02/05

Posts: 5,193

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

Crying

xedon

Reply To Post Reply & Quote

Posted at: 9/20/08 02:33 PM

xedon DARK LEVEL 08

Sign-Up: 09/06/07

Posts: 243

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

lol


None

xedon

Reply To Post Reply & Quote

Posted at: 9/20/08 02:36 PM

xedon DARK LEVEL 08

Sign-Up: 09/06/07

Posts: 243

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


None

zuperxtreme

Reply To Post Reply & Quote

Posted at: 9/20/08 02:53 PM

zuperxtreme NEUTRAL LEVEL 08

Sign-Up: 01/02/05

Posts: 1,599

Looks good. Probably use it. :)

Cheers.


None

xedon

Reply To Post Reply & Quote

Posted at: 9/20/08 02:55 PM

xedon DARK LEVEL 08

Sign-Up: 09/06/07

Posts: 243

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

Cheers.

Your welcome ^^

lol


None

El-Presidente

Reply To Post Reply & Quote

Posted at: 9/20/08 02:55 PM

El-Presidente LIGHT LEVEL 27

Sign-Up: 06/02/05

Posts: 5,193

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

None

TheFunkyMunk

Reply To Post Reply & Quote

Posted at: 9/20/08 03:05 PM

TheFunkyMunk DARK LEVEL 04

Sign-Up: 12/08/07

Posts: 91

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...


None

xedon

Reply To Post Reply & Quote

Posted at: 9/20/08 03:22 PM

xedon DARK LEVEL 08

Sign-Up: 09/06/07

Posts: 243

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

lol


All times are Eastern Standard Time (GMT -5) | Current Time: 10:18 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!