1 Reply Latest reply on Nov 10, 2011 10:39 AM by jfb00

    Problem adding grid items in code

    David1024Mac

      Hi All

       

      I've got a problem creating a grid dynamically in code.

      The Grid and the rows are created without a problem and I can reference them, but when I try to add a gridItem I get a 1009 error.

       

      any ideas?

       

      for (var j:int = 1; j <= mCols; ++j)

                                                                  {

        // add column here

                                                                            lColName = "mR" + i + "col" + j;

       

                                                                            try {

       

                                                                                      myRow = mGrid.getChildByName(lRowName) as GridRow;

       

                                                                            } catch (someError:Error)

                                                                            {

                                                                                      erMsg  += "Get row: " + lRowName + someError.message;

                                                                            }

       

                                                                            try {

                                                                                      var mtCol:GridItem = new GridItem();

                                                                                      mtCol.id=lColName;

       

                                                                            } catch (someError:Error)

                                                                            {

                                                                                      erMsg += "Create GridItem: " + lColName + someError.message;

                                                                            }

       

       

                                                                            try{

        // THis is where the error occurs!

                                                                                      myRow.addChild(mtCol);

                                                                            } catch (someError:Error)

                                                                            {

                                                                                      if (chkErr == true)

                                                                                      {

                                                                                      erMsg += "Add Child: " + lColName + someError.message + "\n";

       

                                                                                      }

                                                                            }

       

       

                                                                  }