1 Reply Latest reply on Apr 2, 2007 7:51 AM by kglad

    creating an Object....

    DZ-015 Level 1
      Ok - so I have two objects...

      var oLibrary:Object = new Object();
      var oBook:Object = new Object();

      and one of them has some values...

      oBook.title = "Happy Book";
      oBook.author = "Ted";

      so. Now I want to duplicate the oBook object within the oLibrary object several times, with different keys... like so...

      oLibrary.red = oBook;
      oLibrary.green = oBook;
      oLibrary.blue = oBook;

      ...but, as I understand it, simple variables (numbers, strings, booleans) assign by duplication. Objects, however, assign by passing a pointer. If I do what I typed above, I believe I will simply have 1 object, and a whole bunch of ways to reference it. (ie, if I change oBook.title, the ".title" property of all the objects will change)

      Correct me if I'm wrong. Give me a better way to do this if I'm right.

        • 1. Re: creating an Object....
          kglad Adobe Community Professional & MVP
          you could just define oLibrary.red to be a new Object(), if you're not ready to specify which object it is.

          if you want to specifiy that it's a generic oBook object that has all the methods and properties of the your oBook, you should create a book class and assign a member of the class to your library property. if you follow that logic, you may want to create a library superclass.