Subscribe

  • Subscribe  

make a wish – right click (example)

Posted by Charles | November 21, 2006 .

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);
		}
	}
}

Leave a Comment

If you would like to make a comment, please fill out the form below.


Name

Email

Website

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Comments

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word


Related Posts

6 Comments so far
  1. mrinal  November 21, 2006 2:19 pm

    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

  2. Flexguy  November 21, 2006 3:26 pm

    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.

  3. mrinal  November 21, 2006 3:36 pm

    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

  4. Flexguy  November 21, 2006 3:43 pm

    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"?>




  5. mrinal  November 21, 2006 3:58 pm

    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

  6. mrinal  November 23, 2006 12:58 pm

    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

<

Error. Page cannot be displayed. Please contact your service provider for more details. (17)


Direct TV Offers - usdirect has the best directtv deals