1 Reply Latest reply on Jan 26, 2008 10:02 AM by robdillon

    loop problem

    phil1943 Level 1
      Hello, sorry for this basic question but I cant seem to allocate my loop variable "i" to my trace(this....) statement.
      How can I do it ? The way I have it below is not working.
      Thanks kindly.

      for (i = 0; i < 6; i++) {
      trace(this+i._x);
      }
        • 1. Re: loop problem
          robdillon Most Valuable Participant
          Do you have objects names "this1", etc.? If that's the case then you want:

          trace(this["this"+i]._x);

          In order to concatenate a variable's value to alpha characters, you need to express those characters as a string. The result of the concatenation is a string. The result, "this0", for instance can't be directly evaluated as the name of a symbol instance on the stage. While you could use the eval() method to resolve the string to an object refererence, you shouldn't. Resolve it using the array of the object that contains it. In this example I'm using the keyword "this".

          This is a reserved word in Actionscript. So, while you are using it as part of the names of your objects, its still a bad idea. Try to us a more descriptive word to define your objects.