3 Replies Latest reply on May 4, 2006 11:21 PM by NismoBrothers

    Counting letters in a field

      I have a field and for example inside it has the word "hello" and the "llo" in the text is red and the "he" is in gray... I want a script so that in the message window, it displays the number of words either in gray or red.. please help me find it ASAP
        • 1. Re: Counting letters in a field
          Chunick Level 3
          let me help you by asking a few questions:

          1. first, how would you get a character from a field member? member("some_field").char[1]
          2. next how would you get the colour of that character? member("some_field").chare[1].color
          3. after that, how would you then loop through each character in a member?

          Now, as for words... well, it's very similar, but you have to be a bit clearer as to what you want - characters or words.
          • 2. Re: Counting letters in a field
            NismoBrothers Level 1
            Right now here is my script which still has a problem... Help me find out why..

            mySprite.member.char[inds[cnt]].color = color(#PaletteIndex, 6)

            inds = []

            repeat with cnt = last to myWord.count

            mySprite is just the sprite member...

            I am not sure why it would not work but there should only be a little change that is needed....
            • 3. Re: Counting letters in a field
              NismoBrothers Level 1
              sorry... it is actually this script.. .my mistake

              put (member("words").char[inds].color = color(#PaletteIndex, 6)).count