1 Reply Latest reply on Dec 14, 2006 7:26 AM by Newsgroup_User

    Get line x from string

    edb00 Level 1
      I need to do the following type structure on a string in Flash where tSTNames is a string
      This is typical director Lingo i would use to do this.

      repeat with i = 1 to tStNames.line.count
      tName = tStNames.line
      --stuff
      end repeat

      I know this will need to be a for loop of some kind but I don't see any easy way to get a line count or to extract a line of text at a time from the string.

      I keep hearing how wonderful Flash is -- but here's a simple string parsing need and it sure doesn't look easy.
      Must be missing something.

      Thanks
        • 1. Re: Get line x from string
          Level 7

          You might want to take a litle peek at the String object.



          var s = "line 1\nline 2\nline 3\nline 4"
          var lines:Array = s.split("\n");

          trace("There are " + lines.length + " lines in: \n" + s);
          trace("");

          for(var i=0; i<lines.length; i++){
          trace("line "+i+" is " + lines )
          }