0 Replies Latest reply on Oct 16, 2007 10:39 PM by Prasad999

    Dynamically loading context menu

    Prasad999
      Hi,
      I am dynamically loading context menu as per XML.
      As I am doing it dynamically, only one callback function is used.
      Problem arises here.
      One callback function is not able to identify which menuitem is clicked.
      If I am able to identify which menuitem is clicked, so I can do different things for every menu in single function.


      function generateRef()
      {
      trace("inside generate reference:generating references for individual screen");
      for(var i=0;i<resObj.firstChild.childNodes.length;i++)
      {
      var str = datObj.getCurrent().attributes["path"];
      var string:Array = str.split(">");
      if(string[0] == resObj.firstChild.childNodes.attributes["name"])
      {
      for(var j=0; j<=resObj.firstChild.childNodes.childNodes.length-1; j++)
      {
      if(datObj.getCurrent().attributes["id"] == resObj.firstChild.childNodes.childNodes[j].attributes["id"])
      {
      var PD = new ContextMenuItem("PD", dummy, true, false, true);
      scrRef.customItems.push(PD);
      for(var a=0; a<resObj.firstChild.childNodes.childNodes[j].attributes["PDLink"]; a++)
      {
      var z=a+1;
      PDLArr[a]=_root.resObj.firstChild.childNodes.childNodes[j].attributes["PDL"+z];
      PDNArr[a]=_root.resObj.firstChild.childNodes.childNodes[j].attributes["PDN"+z];
      var str = PDNArr[a];
      var curRef = new ContextMenuItem(str, clicking, false, true, true);
      scrRef.customItems.push(curRef);
      }
      var MK = new ContextMenuItem("MK", dummy, true, false, true);
      scrRef.customItems.push(MK);
      for(var b=0; b<resObj.firstChild.childNodes.childNodes[j].attributes["MKLink"]; b++)
      {
      var z=b+1;
      MKLArr=_root.resObj.firstChild.childNodes.childNodes[j].attributes["MKL"+z];
      MKNArr=_root.resObj.firstChild.childNodes.childNodes[j].attributes["MKN"+z];
      var str = MKNArr;
      var curRef = new ContextMenuItem(str, clicking, false, true, true);
      scrRef.customItems.push(curRef);
      }
      var EW = new ContextMenuItem("EW", dummy, true, false, true);
      scrRef.customItems.push(EW);
      for(var c=0; c<resObj.firstChild.childNodes.childNodes[j].attributes["EWLink"]; c++)
      {
      var z=c+1;
      EWLArr[c]=_root.resObj.firstChild.childNodes.childNodes[j].attributes["EWL"+z];
      EWNArr[c]=_root.resObj.firstChild.childNodes.childNodes[j].attributes["EWN"+z];
      var str = EWNArr[c];
      var curRef = new ContextMenuItem(str, clicking, false, true, true);
      scrRef.customItems.push(curRef);
      }
      var WP = new ContextMenuItem("WP", dummy, true, false, true);
      scrRef.customItems.push(WP);
      for(var d=0; d<resObj.firstChild.childNodes.childNodes[j].attributes["WPLink"]; d++)
      {
      var z=d+1;
      WPLArr[d]=_root.resObj.firstChild.childNodes.childNodes[j].attributes["WPL"+z];
      WPNArr[d]=_root.resObj.firstChild.childNodes.childNodes[j].attributes["WPN"+z];
      var str = WPNArr[d];
      var curRef = new ContextMenuItem(str, clicking, false, true, true);
      scrRef.customItems.push(curRef);
      }
      }//end of if id
      }//for
      }//if
      }//for
      }


      In for loop I am inserting context menu, but callback function is same, which is 'CALLING'. I want to detect for which menu item CALLING function is called.

      Please help ASAP.

      Thanks in advanced.