1 Reply Latest reply on Apr 18, 2006 10:35 AM by ntsiii

    problem in display context menu in flex1.5

      hi all,

      i have one problem in creating context menu in flex1.5

      i have created one mxml file and in that i have include this script tag
      <mx:Script source="test.as"/>

      now code of test.as file are as below

      // ActionScript Document
      var showItem = true; // Change this to false to remove

      function menuHandler(obj, menuObj) {
      if (showItem == false) {
      menuObj.customItems[0].enabled = false;
      } else {
      menuObj.customItems[0].enabled = true;
      function itemHandler(obj, item) {
      //...put code here...
      var my_cm:ContextMenu = new ContextMenu(menuHandler);
      my_cm.customItems.push(new ContextMenuItem("Hello", itemHandler));
      _root.menu = my_cm;

      but when i am trying to run mxml file it show err due to as file below mentioned statement

      my_cm.customItems.push(new ContextMenuItem("Hello", itemHandler));
      _root.menu = my_cm;

      and error msg is
      this statement is not permitted in a class definition

      so can anybody suggest me what is solution to display context menu properly..

      thanks in advance...