Build 10 classic Flash games and learn game development along the way with this ultra-fast paced game development course.

If you love this blog, this is the book for you.

Buy the book

Get the source code of 12 commercial Flash games, which have been loaded more than 50 million times!

Learn from real world successful examples.

Get it now

Box2D for Flash Games teaches you how to make Flash physics games from scratch with the most advanced features.

Create the new Flash game smashing hit.

Buy the book

Easily handle right mouse button in Flash movies

Detecting and handling right mouse clicks in Flash has always been a pain.

I blogged about it four years ago in the post preventing the right mouse cheat in your Flash games where I explained a dirty trick to trigger right mouse button with As2, and guess what? Things got even worse with As3, although I found a workaround preventing players to cheat in my Flash game Stringy.

Finally, the pain is over. With Flash Player 11.2, you can finally do everything you want in Flash movies, without exporting them for Air.

Look at this movie:

You can use left mouse button to drag boxes, and right mouse button to destroy them. Also notice, the default right click menu does not appear.

Look at the source code:

Without entering in detail into Box2D coding, which is just the drag and drop example you can find in the official demo, look at the listener at line 39, which is the core of the script.

Then, you can easily publish the movie for Flash Player 11.2, thanks to Flash Professional CS6 you can download and try for 30 days at this link.

Just notice right mouse clicks examples will only work in browsers, testing them from the Flash IDE won’t work.

What else to say? How many new game concepts can you imagine using both left and right mouse buttons?

Download the source code.

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (10 votes, average: 4.30 out of 5)
Loading ... Loading ...
Flash Templates provided by Template Monster are pre-made web design products developed using Flash technology.
They can be easily customized to meet the unique requirements of your project.
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 8 comments

  1. Chris

    on June 5, 2012 at 12:23 am

    It’s nice that you don’t have to use JavaScript anymore to try to handle right-clicks
    I guess this will also make it harder to distinguish if something is flash or html5 just by right-clicking on it ;) Maybe that is their motivation for finally adding it?

    I wonder if they just added their own JS file to handle, and pass back right clicks, since it doesn’t work outside of the browser?

  2. kaes

    on June 5, 2012 at 7:24 am

    Hmm I still can see right-click menu and boxes do not disappear after right-clicking on them. There is no difference for me (chrome browser)

  3. Lunux

    on June 6, 2012 at 8:52 am

    Another way to do it(min req Flash Player 9)

    import flash.events.ContextMenuEvent;
    import flash.ui.ContextMenu;

    var cmenu = new ContextMenu();
    cmenu.addEventListener(ContextMenuEvent.MENU_SELECT , menuSelectHandler);
    contextMenu = cmenu;

    function menuSelectHandler(e:ContextMenuEvent):void
    {
    trace(“you are cheating!!!”);
    }

  4. David

    on June 6, 2012 at 3:02 pm

    Shame it doesn’t work outside the browser, as some of our flash games are now developed as standalone files. :-(

  5. Pablo

    on June 7, 2012 at 3:51 pm

    Yeah, its nice indeed, the only problem so far is that Starling doesn’t support it, I hope that situation will change soon.

  6. Husky

    on June 8, 2012 at 9:43 am

    Cool!
    Waiting for too long!

  7. paala

    on June 19, 2012 at 3:52 pm

    If you are using flash develop 4.0.3 you don;t have to open the swf in browser.

  8. luis

    on June 24, 2012 at 3:12 am

    ufff ahora si voy a poder quitar ese molesto menĂº, gran aporte emanuele gracias