2 Replies Latest reply on Aug 15, 2008 10:39 AM by Gregory Lafrance

    Object Array

    Arsal_u1
      Hi!
      Explaining my Point in Detail; I will say that Suppose I have designed a class say 'A', Now if this class have different variables and member functions then obviously we may access them by creating object of that class i.e
      var ob1:A = new A();
      Now with this we have created an object of class 'A', Now I please want to know that Is this Possible that I can create array of object of class 'A' ie, 'ob1' in such a way that at every index of 'ob1' we may access seperate Member Functions etc just like we can do in C++ etc.
      Thanks
        • 1. Re: Object Array
          Level 7

          "Arsal_u1" <webforumsuser@macromedia.com> wrote in message
          news:g8353u$9li$1@forums.macromedia.com...
          > Hi!
          > Explaining my Point in Detail; I will say that Suppose I have designed a
          > class
          > say 'A', Now if this class have different variables and member functions
          > then
          > obviously we may access them by creating object of that class i.e
          > var ob1:A = new A();
          > Now with this we have created an object of class 'A', Now I please want to
          > know that Is this Possible that I can create array of object of class 'A'
          > ie,
          > 'ob1' in such a way that at every index of 'ob1' we may access seperate
          > Member
          > Functions etc just like we can do in C++ etc.

          private var objArray:Array=makeObjects();

          function makeObjects():Array{
          var tmpArray:Array=new Array();
          for (var i:int=0; i<5; i++){
          tmpArray.push(new ob1());
          }
          trace(tmpArray[0].toString());
          return tmpArray;
          }


          • 2. Re: Object Array
            Gregory Lafrance Level 6
            You may find this example even more comprehensive and relevant. A.as must be in directory "components" and you need to run in debug mode to see the trace output.