0 Replies Latest reply on Aug 25, 2006 9:10 PM by Newsgroup_User

    Re: dynamically creating variables inside of a loop

    Level 7
      var data_array:Array = Array(3);
      myArray.push = "first";
      data_array.push("third", "second", "first");

      for (i=0; i<data_array.length; i++) {
      this["team"+i+"Score"] = data_array ;

      trace(this["team"+i+"Score"]);

      }


      --

      Dan Mode
      --> Adobe Community Expert
      *Flash Helps* http://www.smithmediafusion.com/blog/?cat=11
      *THE online Radio* http://www.tornadostream.com
      *Must Read* http://www.smithmediafusion.com/blog


      "Christopher Hayes" <chris.hayes@maritz.com> wrote in message
      news:ecno7m$eq1$1@forums.macromedia.com...
      > Flash 8, AS 2
      >
      > Let's say i'm looping through an array and want to create variables from
      > elements in that array, like this:
      >
      > for (var i:Number = 0; i < data_array; i++) {
      > // create a variable in the format team1Score = 5
      > this["team" + i + "Score"] = data_array[0];
      > }
      >
      > Obviously, Flash won't let me do this, so how do I accomplish what i'm
      > trying to do?
      >
      > Thanks,
      >
      > Chris
      >
      >
      >