2 Replies Latest reply on Mar 1, 2011 9:21 AM by Jerry62712

    How do I get "Application.application" to work

    Jerry62712 Level 1

      In my continuing quest to solve a print problem, I keep getting other errors.

       

      the lastest is "Application.application.addChild(someObject)" not working.  Here is the 1st message:

      1119: Access of possibly undefined property application through a reference with static type Class.

       

      Here is the 2nd message:

      1195: Attempted access of inaccessible method validNextPage through a reference with static type
      mx.printing:PrintDataGrid.

       

      Here is the 3rd message:

      Multiple markers at this line:
      -1119: Access of possibly undefined property application through a reference with static type Class.
      -AS3

       

      (note "AS3" is one of the code assist options - application is not an option)

      Here is the code:

      <?xml version="1.0" encoding="utf-8"?>
      <options:OptionContent
          xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:options="gov.il.dhs.wvs.view.options.*"
          xmlns:cust="cust.*"
          creationComplete="_init();"
          show="showHandler(event)">
      ...
                      var numNotes:int = model.dpCASENOTES.length;
                      if (numNotes > 0)
                      {
                          var dataSource:ArrayCollection = new ArrayCollection();
                          for (var i:int = 0; i < numNotes; i++)
                          {
                              var dataHolder:Object = new Object();
                              dataHolder.NoteNum = (model.dpCASENOTES[i] as CaseNotesVO).notes.toString();
                              dataHolder.UpdatedBy = (model.dpCASENOTES[i] as CaseNotesVO).updatedBy.toString();
                              dataHolder.PostedDate = (model.dpCASENOTES[i] as CaseNotesVO).postTs.toString();
                              dataHolder.Description = (model.dpCASENOTES[i] as CaseNotesVO).shortDescription.toString();
                              dataHolder.Notes = (model.dpCASENOTES[i] as CaseNotesVO).notes.toString();
                              dataSource.addItem(dataHolder);
                          }
                          var printJob:FlexPrintJob = new FlexPrintJob();
                          if (printJob.start())
                          {
                              var myGridPrint:PrintDataGrid = new PrintDataGrid();
      ==>                        Application.application.addChild(myGridPrint);
                              myGridPrint.dataProvider = dataSource;
                              myGridPrint.width = printJob.pageWidth;
                              myGridPrint.height = printJob.pageHeight;
                              printJob.addObject(myGridPrint);
      ==>                        while (myGridPrint.validNextPage())
                              {
                                  myGridPrint.nextPage();
                                  printJob.addObject(myGridPrint);
                              }
      ==>                        Application.application.removeChild(myGridPrint);
                              printJob.send();
                          }

       

      This is a component (CaseNotes.mxml).  There might be a scope of names thing going on.