welcome to my space


Recent Posts

Categories

Blogroll

Meta

  1. RSS
  2. valid XHTML

new object not getting defined within class.

wktd | March 14, 2010 | | portal.polala.com

  • Hi. I'm trying to make 500 objects (boxZ0Z0,boxZ0Z1,...) each with a distinct id "i". I'm getting 500 objects: trace for "this["boxZ"+a+"Z"+b].id" returns 500 statements, but each value returns undefined...my helper code calls for:

    import globalMap
    var globalMap1:GlobalMap = new GlobalMap();


    class GlobalMap {
    var globalMap:Object = new Object();
    var b:Number = 0;
    var a:Number = 0;
    function GlobalMap(){
    for(var i:Number=0; i<500; i++) {
    this["boxZ"+a+"Z"+b] = new Object();
    this["boxZ"+a+"Z"+b].id = i;
    a = a+1
    trace(this["boxZ"+a+"Z"+b].id)
    if(a==250){
    a = 0;
    b = b +1;
    }
    }
    }

    }

    help?


  • one way:

    class GlobalMap {
    var ObjectsAr:Array = new Array();

    var b:Number = 0;
    var a:Number = 0;

    function GlobalMap(){
    for(var i:Number=0; i<500; i++) {
    ObjectsAr[i] = new Object();
    ObjectsAr[i].nameval = "boxZ"+a+"Z"+b;
    ObjectsAr[i].id = i;
    a = a+1
    trace(ObjectsAr[i].nameval+" --- "+ObjectsAr[i].id)
    if(a==250){
    a = 0;
    b = b +1;
    }
    }
    trace("-------------------- "+ObjectsAr[50].nameval)
    }

    }


  • hey, it works ! thx :) its alive !
    ObjectsAr[255].nameval returns "boxZ5Z1", or xy value>> (5, 1)
    its alive !


  • oh, - is there some way for it to be ObjectsAr["boxZ"+a+"Z"+b] so that to change nameval/id or one of its attributes to something like "not default" I can call for: ObjectsAr[boxZ10Z0].nameval = "not default" instead of having to call:


    for(i in ObjectsAr[i]){
    if (ObjectsAr[i].nameval = boxZ10Z0){
    ObjectsAr[i].id = "not default";
    }


    ??
    thx







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about new object not getting defined within class. , Please add it free.
    edit

    Can anyone tell me the name of the painting/poster Chuck Bass has hanging on his bedroom wall over his bed? Can you help me solve this physics problem?