3 Replies Latest reply on Jun 6, 2008 8:59 AM by Gregory Lafrance

    preoblem with a final class

    jjales
      hello

      I would like to build a specific subclass of contextmenuitem :
      my idea is that, when selected, this menu shall set a specific attribute of a target object, using a given value.
      something like :
      public function set_attrl( ev: ContextMenuEvent ):void{
      this.target_object[this.target_attribute] = this.value;
      }

      thus, I would like to add the 3 attributes to the contextmenuitem builder, and also link the selection event to this function.

      unfortunately, this class is final...

      is there any work around ?

      thanks !
        • 1. Re: preoblem with a final class
          slaingod Level 1
          Haven't worked too much with that, but is this something that could be done with the generic 'data' Object assuming the contextMenuItem has one?
          • 2. Re: preoblem with a final class
            jjales Level 1
            sorry, I don't understand ?
            • 3. Re: preoblem with a final class
              Gregory Lafrance Level 6
              Context menus have llimited functionality in Flex, meaning you cannot just add whatever you want to them whenever you would like.

              See this FB3 help topic: About context menus

              If you use the ContextMenu class, you must use the ContextMenuItem class with it; you cannot add NativeMenuItem objects to a ContextMenu object, nor can you add ContextMenuItem objects to a NativeMenu object.

              The primary drawback to using the context menu API is that it does not support submenus.

              Although the ContextMenu class includes methods, such as addItem(), that are inherited from the NativeMenu class, these methods add items to the incorrect items array.

              In a context menu, all items must be added to the customItems array, not the items array. Either use NativeMenu objects for context menus, or use only the non-inherited ContextMenu methods and properties for adding and managing items in the menu.