0 Replies Latest reply on Aug 23, 2007 5:52 AM by Newsgroup_User

    How to access an object from a class without DisplayObject

    Level 7
      I've created two classes: ABC and XYZ

      The class ABC extends Sprite and I declare it like this:

      for (var i:int=0; i<5; i++) {
      var abc:ABC = new ABC();
      abc.name = "abc_"+i;

      If I want to have access to it, I do something like this:

      for (var j:int=0; j<5; j++) {

      The class XYZ it's a "standalone" class that does not extends or import
      any other class, and here it is how I declare it:

      var xyz_01 = new XYZ();


      BUT, if I can't figure how to declare it and/or reference to it dynamically.

      for (var i:int=0; i<5; i++) {
      this['abc_0'+i] = new XYZ();

      for (var j:int=0; j<5; j++) {
      trace(this.getChildByName('abc_0'+j).getValue()); // seems that
      getChildByName does not work because it the object doesn't have a name
      and is not added as a child on the stage
      trace(this['abc_0'+j].getValue()); // this one only works if I replace
      the "j" for a "4" (abc_04 was the last one created) otherwise I get
      "TypeError: Error #1010"

      So, it could be declared correctlt, but since I can't use their methods
      I cannot tell, any clues on this?