2 Replies Latest reply on Oct 8, 2009 3:36 PM by RedOctober57

    Test if Object is Assigned()   meaning...  not null

    RedOctober57

      In Delphi using the Windows SDK, I can use the Assigned() function to determine if an object has been instantiated... IOW... not null.  How is this done in ActionScript?  I've been going around in circles in the documentation.  I can find every keyword, and operator, but I can't find how to test for a null object variable.

       

      if (MyDataGrid.selectedItem is not null) {..my..code..}

       

      Thanks in advance.

        • 1. Re: Test if Object is Assigned()   meaning...  not null
          paul.williams Level 4

          if ( MyDataGrid.selectedItem != null ) {..my..code..}

           

          or

           

          if ( !MyDataGrid.selectedItem ) {..my..code..}

          • 2. Re: Test if Object is Assigned()   meaning...  not null
            RedOctober57 Level 1

            Hi p_m, I tried what you suggested first and got errors, but the errors must have been caused by a } out of place or something.

             

            I'm having trouble with testing more than one var for assignement.  No matter how I switch around the syntax, I get an error.  Can you tell me how to fix the following code?   I need to test if the grdSESs is instantiated *before* I test it's .selectedItem property.  The following will "compile" but throws an error when running.

             

                            if (grdSBJs.selectedItem != null)
                                {lblSelectedSBJ.text = grdSBJs.selectedItem.SBJ_NM};
                          if ((grdSBJs.selectedItem != null) && (grdSESs.selectedItem != null))
                            {lblSelectedSBJ.text = grdSBJs.selectedItem.SBJ_NM + ', ' + grdSESs.selectedItem.SES_TYP}   // <-- Throws error here