Right-Click Action

Hello,

I am working on a software simulation project where we need a right-click action. Basically, if the user right-clicks in the right spot, it will bring them to the next question. Does anyone know how to accomplish this in AS2 or Lectora?

Thank-you in advanced.

Discussion (10)

I don't know too much about flash. A right-click on a flash animation will normally open the flashplayer context menu. I don't know whether that can be prevented.

Tim

Just out of curiosity, do you know of a way to do this in AS2? We are building the simulations mainly in Flash and for consistency purposes would like to know if there is a way to do this in Flash as well.

Thank-you in advanced.

Almost anything you can do in Flash ( As2 or As3 ) can nowadays be done in Javascript with the use of the proper libraries or in plain 'vanilla' Javascript. Big advantage of doing things without Flash offcourse is that it is compatible with iPads and mobiles.

Unfortunately, I do not know JavaScript, so I was hoping for an easy AS2 fix without getting JavaScript involved at this point in time, but I am not sure that solution exists.

Okay, no problem. I know the context menu can be disabled to an extent, but I am not sure about completely (at least not without Javascript I believe).

In either case, it looks like no easy task to get a right-click function in Flash, so I was hoping someone might be able to offer a simpler solution without getting into some heavy duty JavaScript. Knowing it can be done in Lectora now, we may have to go in that direction instead of AS2.

Thank-you again.

Thank-you very much for your reply. I am new to Lectora and wasn't even aware that right-click was an option, I thought it was only left-click. This will solve the issue.

Thank-you again.

On: Right Mouse Click is an available trigger for most objects.

Tim

right-click.jpg

Indeed as Sergey mentioned. As2 is almost Javascript. I did programme in As2 and As3... and found the change to Javascript easy. Especially when you check upon JS libraries like GSAP ( Greensock ) or CreateJS ( developed by Grant Skinner, one of the best known Flash developers in former days )

Thank-you both for the feedback. I tried the code that Sergey Snegirev posted before and unfortunately the default context menu will still show up even if the function on right click works. I know the menu can be removed to an extent with the Settings and About... options still showing up, but is there a way to get rid of it all together? Is there some kind of option in Lectora maybe to disable the right click menu on SWF files or will that get rid of the right-click function altogether?

I wasn't aware that JavaScript and AS2 were so similar. I will have to take a look at it later on when time permits, especially since Flash seems like it is on its way out the door nowadays.

In AS2 you have to use ContextMenu object, e.g.

function onRightClick() {

// whatever you need to do on right click

}

var myMenu:ContextMenu = new ContextMenu(onRightClick);

_root.menu = myMenu;

Also, JavaScript and ActionScript are based on ECMAScript, so switching from AS2 to JS is super easy, it is basically the same language.

Discussions have been disabled for this post