2 Replies Latest reply on Nov 25, 2007 1:19 PM by ananjar

    text members an lists

    ananjar
      Hi,
      I'm in trouble with the text's cast members and the lists. If I want to put into a list the contain of a text cast member, I must create a list, and send all the characters os the text step by step.
      The text member "texto" is not empty. A loop with repeat with from the last character os the word to the first(0); and it's addig to the list with the command add, but the code is not correct because director emits a message error connected with the lista.add(member("texto").char[num_letras]). char[num_letras] is the guilty (!?) told me the program. I don't understand why. I don't find another command to use, getOne, append, ... there are not avaible, totally unuseful.
      somebody could help me please?
      Thanks a lot!
      I can post the director file too if somebody want to help me. All of this is for an escalable project with sensors sending signals throught the serial port with an Xtra.
        • 1. Re: text members an lists
          Level 7
          > on enterframe
          >
          > array=list(member("texto").text)
          > num_letras=member("texto").char.count
          > aleatoria=random(num_letras)
          >
          > lista=member("texto").char[1])
          > repeat while (num_letras>0)
          > lista.add(member("texto").char[num_letras])
          > num_letras=num_letras-1
          > end repeat
          > array=list(member("texto").text)
          > end


          A few things:
          'lista' is defined as a string (lista=member("texto").char[1]) but you
          then try to add to it as if it were a list.
          You define a (local?) variable 'aleatoria' but don't seem to use it.
          You define/initialise/set a (local/property?) variable 'array' twice
          unnecessarily.

          Try:
          --
          on enterframe
          array=list(member("texto").text)

          num_letras=member("texto").char.count
          lista=[]
          repeat with n = num_letras down to 1
          lista.append(member("texto").char[n])
          end repeat
          end
          • 2. Re: text members an lists
            ananjar Level 1
            Ok. I'll try it. Thanks.