3 Replies Latest reply on Aug 3, 2006 3:59 PM by Lord Bron

    Dynamic variable

    doug777 Level 1
      I want to add pages to an accordion component. The following code doesn't work:

      //some_number_between_1_and_10 returned from database call

      var numpages:uint = some_number_between_1_and_10;
      var cnum:String;

      for(var i:uint=0; i<numpages; i++){

      cnum = "c"+i;
      this[cnum]:Canvas = new Canvas();
      this[cnum].label = "Page "+(i+1);


      The first use of this[cnum] returns the error: Label must be a simple identifier.

      So how do I set and use a dynamic variable?