

Guess just talking is not enough. Dug into our code. One way to do it is here. It’s kinda primitive and have to dip into Flash API. Wish Flex has more elegant way of doing it. (seems I need a better wordpress code plugin, any suggestion?)
var oldRootMenu;
var selectedIndex:Number;
function rightClick(){
var my_cm = new ContextMenu(menuHandler);
my_cm.customItems.push(new ContextMenuItem("Generate Financial Status PowerPoint Slide", itemHandler));
my_cm.customItems.push(new ContextMenuItem("Generate Technical Status PowerPoint Slide", itemHandler));
my_cm.customItems.push(new ContextMenuItem("Generate Risk Status PowerPoint Slide", itemHandler));
oldRootMenu = _root.menu;
_root.menu = my_cm;
_root.menu.hideBuiltInItems();
my_cm.builtInItems.print = true;
function menuHandler(obj, menuObj) {
if (_root.curStatus == _root.curStatusType[0].Financial) {
menuObj.customItems[0].enabled = true;
menuObj.customItems[1].enabled = false;
menuObj.customItems[2].enabled = false;
}
else if (_root.curStatus == _root.curStatusType[0].Technical){
menuObj.customItems[0].enabled = false;
menuObj.customItems[1].enabled = true;
menuObj.customItems[2].enabled = false;
}
else if (_root.curStatus == _root.curStatusType[0].Risk){
menuObj.customItems[0].enabled = false;
menuObj.customItems[1].enabled = false;
menuObj.customItems[2].enabled = true;
}
}
function itemHandler(obj, item) {
//HTTP Post object
var httpPostData:httpPost;
if(httpPostData==null || httpPostData==undefined){httpPostData = new httpPost();}
if(item.caption=="Generate Financial Status PowerPoint Slide" && item.enabled==true)
{
var httpPostFin : httpPostFinancialData = new httpPostFinancialData();
httpPostFin.assignFinancialProjectValues(_root.financialGrid);
httpPostData.getChart("http://pdmstestwss:8080/fileDownload.aspx/",httpPostFin);
}
else if(item.caption=="Generate Technical Status PowerPoint Slide" && item.enabled==true)
{
var httpPostTech : httpPostFinancialData = new httpPostFinancialData();
httpPostTech.assignTechnicalProjectValues(_root.projectGrid);
httpPostData.getChart("http://pdmstestwss:8080/fileDownload.aspx/",httpPostTech);
}
else if(item.caption=="Generate Risk Status PowerPoint Slide" && item.enabled==true)
{
var httpPostRisk:httpPostRiskData = new httpPostRiskData();
httpPostRisk.assignRiskProjectValues(_root.riskGrid);
httpPostData.getChart("http://pdmstestwss:8080/fileDownload.aspx/",httpPostRisk);
}
}
}
If you would like to make a comment, please fill out the form below.
| Cox packages ||| Verizon Satellite TV ||| Comcast cable offers |
I’m new to this world of flash and flex, please help me out … I am looking at the Flex 2 language reference and I don’t see a constructor for ContextMenu that accepts an argument, there is just one no-argument constructor
I wonder if the above code will work??
Mrinal
That’s exactly why we made the wish. The ContextMenu is from flash API. Flex doesn’t have a grace way of doing it. The example above works but is more or less a hack, from Flex point stand. That’s because most Flex developers are not from Flash world, rather, from Java or alike crowd.
I see … even if its a hack … how exactly can I make it work in Flex? What has been done here? http://www.flex-flex.net/flex/RightClickMenu/RightClick.html
I put the above code in flexbuilder and it did what I expected “ERROR”
Thank you for all the help,
Mrinal
The example you provide is actually more deeper and complex hack than ours and better too. Wish they can give out code.
You can’t just copy and past, for a app you want to use the righclick, you need initialize it as:
< ?xml version="1.0" encoding="utf-8"?>
xmlns:debug="*"
xmlns:local="*" initialize="rightClick()" styleName="colors">
…
how would that help?
at the line “var my_cm = new ContextMenu(menuHandler);” flex builder says “Incorrect number of arguements, expected no more than 0″
Mrinal
I don’t know if anyone noticed but, the Flex-Flex blog now has the code for the above sample that we talked about
http://www.flex-flex.net/blog/article.asp?id=27
Thats a neat approach, any ideas y they have not been able to get it working on other browsers ???
Mrinal