Tutorial: Custom right-click menu for Adobe Captivate

1

Wouldn’t it be nice to add your own custom right click menu to your Adobe Captivate projects?  Actually that’s a pretty simple task using a little Flash file to “inject” a new menu and substitute the standard Captivate / Flash menu with that. You could add information about who developed the project, link to your website, contact details etc.

Here is a little tutorial on how to create such a custom right-click menu in Flash (AS2) and add it into Adobe Captivate.

Demonstration:

The movie below has the regular / standard Adobe Flash and Adobe Captivate right-click menu:

[swfobj src=”http://www.cpguru.com/wp-content/captivateRegularRightClickAS2.swf” width=”400″ height=”335″ name=”none2as2″ align=”none” allowfullscreen=”false” required_player_version=”9″]

The movie below has a custom right-click menu:

[swfobj src=”http://www.cpguru.com/wp-content/captivateCustomRightClickAS2.swf” width=”400″ height=”335″ name=”noneas2″ align=”none” allowfullscreen=”false” required_player_version=”9″]

 

The Flash code:

The full code is available below,  but I will go through all the code line-by-line and explain them.

This line will create a variable to hold our custom menu.

1
var customMenu = new ContextMenu();

These two lines is what we will show in the custom menu. You simply insert your own text between the ” ” brackets and that is what will be shown in the menu. Now the important thing here is that you also need an “action” to occur when the user clicks that menu item. This action is usually a function and it can simply be an empty function if you don’t want anything to happen when the user clicks. The function names above are “emptyFunction” and “openWebsite”.

1
2
customMenu.customItems.push(new ContextMenuItem(".: Developed by www.cpguru.com :.", emptyFunction));
customMenu.customItems.push(new ContextMenuItem(" -> Click here to visit our website!", openWebsite));

This will hide the standard right-click menu items.

1
customMenu.hideBuiltInItems();

This will put our custom menu items into the menu.

1
_root.menu = customMenu;

Here is our function called openWebsite. This will execute if the user clicks the associated menu item.

1
2
3
function openWebsite(){
getURL("http://www.cpguru.com", "_blank");
}

Here we have our emptyFunction, which will be executed when the user clicks the associated menu item. Since the function is empty no action will be taken.

1
function emptyFunction(){};

Below here is the full code.

Full code for the custom Adobe Captivate right-click menu:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Custom right click menu that can be used with Adobe Captivate

// setup the new menu
var customMenu = new ContextMenu();

// create the menuitems

customMenu.customItems.push(new ContextMenuItem(".: Developed by www.cpguru.com :.", emptyFunction));
customMenu.customItems.push(new ContextMenuItem(" -> Click here to visit our website!", openWebsite));

// This will hide the regular menu items and substitute the default right click menu with our own menu
customMenu.hideBuiltInItems();

// Subsitute menu with our custom menu
_root.menu = customMenu;
// function to open the URL on click
function openWebsite(){
getURL("http://www.cpguru.com", "_blank");
}

// empty function for the first line of our menu

function emptyFunction(){};

Steps to complete in Adobe Flash and Adobe Captivate:

So what you need to do is to create a new Flash file. Set the size to 100px x 100px as we don’t want to display anything – just execute some code.

Once you have your new Flash file open then click F9 to open up the actions panel and paste in your code. Now you just need to save your Flash file and publish it (CTRL+Enter).

Now you need to insert this Flash file into your Captivate project. Insert it on your first slide and just let it display for the standard 3 seconds. That’s actually all you need to do. Now when you view your published movie and right-click you will see your own custom menu.

A couple of things to keep in mind:

– Once you have injected your custom menu into your Adobe Captivate project you cannot get back the default Flash right-click menu without removing the Flash file and republishing your project.

– It shouldn’t be used in projects where you rely on catching right-clicks in Captivate simulations etc.

Hope you find this useful.

/Michael

Share.