YOUR FEEDBACK
Steve Jobs Not Dying, Press Figures
iPhone News Desk wrote: Apple telling the press that the state of its CEO'...


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
MXDJ TOP LINKS YOU MUST CLICK ON !


Adding Right-Click Functionality to Captivate Content
Instead of trying to avoid right-click events, I have come up with a solution that simulates right-click functionality

Digg This!

Page 2 of 3   « previous page   next page »

I created a special SWF file to handle this responsibility (see the right-click-box.swf file in the sample file at the beginning of this article). Think of this SWF file as Captivate's built-in Click Box. When the animation appears in the Timeline, it specifies the JavaScript to enable right-click functionality. If a slide in your Captivate content requires a right-click to advance, use the following steps as you author your Captivate content:

  • Start Demo: Adding Right Click Functionality to Captivate Content
  • Add a Click Box over the target area.
  • Click the Insert menu, select Animation, and select the right-click-box.swf file.
  • Place the animation over the Click Box.
  • Ensure that the animation does not touch the start or end of the slide in the Timeline.
The animation must not touch the start or end of the slide's Timeline because that could cause problems with enabling right-click functionality on slides before or after the current slide.

After following these steps and publishing your Captivate content as a SWF file, you are ready finally to implement the JavaScript that brings everything together.

Note: Moving data from Captivate to JavaScript in this fashion is outside the scope of this article. Interested Flash developers can examine the right-click-box.fla sample file to see how I do this.

Implementing the JavaScript
The JavaScript can be broken down into three sections. One section acquires the necessary data from the Captivate demo or simulation, another section sets up the shield, and the final section decides what to do when the user right-clicks the shield.

The first section is called when the right-click-box.swf animation starts to play in the Timeline:

// Array to hold data sent by the right-click box we inserted in Captivate
var rightClickBoxData = new Array(4);

// Receive the function call from the movie clip
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
function cp_DoFSCommand(command, args) {
var myFlashObj = InternetExplorer ? cp : document.cp;

// Set the dimensions of the right click box
// rightClickBoxData[0] = x position (relative to Captivate movie)
// rightClickBoxData[1] = y position (relative to Captivate movie)
// rightClickBoxData[2] = width
// rightClickBoxData[3] = height
rightClickBoxData = args.split(" ");

// Enable right click functionality
rightClickToAdvance();
}
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&
navigator.userAgent.indexOf("Windows") != -1
&& navigator.userAgent.indexOf("Windows 3.1") == -1) {
document.write(Œ<SCRIPT LANGUAGE=VBScript\> \n');
document.write(Œon error resume next \n');
document.write(ŒSub cp_FSCommand(ByVal command, ByVal args)\n');
document.write(Œ call cp_DoFSCommand(command, args)\n');
document.write(Œend sub\n');
document.write(Œ</SCRIPT\" \n');
}

When the second section runs, it calls the rightClickToAdvance() function, which enables and positions the shield (Figure 1):

function rightClickToAdvance(){

// Define the shield and Captivate objects
var shield = document.getElementById("shield");
var cp = document.getElementById("cp");

// Enable the shield
shield.style.display = "inline";

// Place the shield over top of only the Captivate SWF file
shield.style.top = cp.offsetTop;
shield.style.left = cp.offsetLeft;
shield.style.width = cp.width;
shield.style.height = cp.height;

// Perform the userRightClicked function when the user press the right mouse button
document.oncontextmenu = userRightClicked;

// Stop the user from being able to select the shield
document.onselectstart = new Function ("return false");
}

The last section of code indicates to the browser that right-clicks should call the userRightClicked() function (Figure 2).

The userRightClicked() function determines whether the user right-clicked a location inside the target area of the right-click box. If the user's right-click was not in the target area, nothing happens. If the user right-clicks the target area, the userRightClicked() function disables the shield, advances the Captivate simulation to the next slide, and returns functionality back to normal:


Page 2 of 3   « previous page   next page »

About Steven Shongrunden
Steven Shongrunden has been developing leading-edge e-learning solutions for the past three years. He is the owner of Sun City Design, an Internet marketing and consulting firm in Canada. He manages all aspects of the company's web development and technical training solutions.

LATEST FLEX STORIES & POSTS
Adobe's Kevin Lynch and Microsoft's Scott Guthrie to Keynote AJAX World RIA Conference & Expo
Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe launched AIR 1.0 in February '08 and Microsoft launched Silverlight (September '07). At the 6th International AJAXWorld RIA Conference & Expo in October SYS-CON Events is delighted to be
4D Releases 4D Web 2.0 Pack v11 Release 2 (11.2)
4D announced the release of 4D Web 2.0 Pack v11 Release 2. The new version, a combination of two products - 4D AJAX Framework and 4D for Flex - brings a powerful set of tools, plug-ins, and components that allow 4D developers to harness the power of Web 2.0 technologies, and deliver li
Cloud Computing - IBM's Got Its Head in the Clouds
Reminding people of how its backing was the making of Linux, IBM, to no one's surprise, has thrown its support behind cloud computing, that delicious nexus of every chi-chi buzzword technology currently in vogue: Web 2.0, rich Internet applications, software-as-a-service, SOA, grid com
Keys to Success When Load Testing Today's Flex Applications
In today's complex web application world, developers need to test applications that go beyond simple HTTP-based pages. They need to test Rich Internet Applications that incorporate complex technologies like Adobe's Flex. Adobe Flex applications may be different from applications you wo
Flex 4 SDK News
Yesterday, a new component architecture and feature specifications were provided to the Flex SDK open source developer community. The Flex team targets three primary teams: design in mind, developer productivity, and framework evolution.
Adobe Gives Yahoo & Google Special Flash Treatment
Adobe says it's going to 'dramatically improve' the search results of dynamic web content and rich Internet applications (RIAs) for Google and Yahoo by giving them optimized Flash Player technology. This new widgetry, which will read and index SWF files, is supposed to uncover informat
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE