1 Reply Latest reply on Nov 21, 2008 3:21 AM by SujitG

    Need to print a particular chart from a page

    Ithu_007
      Hi,

      I have a page showing 4-5 charts. i need to get one particular chart printed when i select the customized right click.
      I'm stuck up here as i dont knw how to pass the object on which i clicked to the contextmenuHandler.
      Can anyone help me pls.

      public function printWidget():void{

      var contextMenu:ContextMenu = new ContextMenu();
      contextMenu.hideBuiltInItems();
      var menuItem:ContextMenuItem = new ContextMenuItem("Print Widget");
      //menuItem.separatorBefore = false;

      menuItem.addEventListener( ContextMenuEvent.MENU_ITEM_SELECT,menuSelectHandler);
      contextMenu.customItems.push(menuItem);

      this.contextMenu = contextMenu;
      }
      private function menuSelectHandler(event:ContextMenuEvent):void
      {
      var tempHeight:int = this.height;
      var tempWidth:int = this.width;
      //var printJob:PrintJob = new PrintJob();

      var printJob:FlexPrintJob = new FlexPrintJob();

      if( printJob.start() )
      {
      this.width = printJob.pageWidth * (8/9)
      this.height = printJob.pageHeight * (8/9)
      printJob.addObject(this);
      }

      printJob.send();

      this.height = tempHeight;
      this.width = tempWidth;
      this.invalidateSize();
      }