dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Compare a string with lines in a file

  1. #1
    Junior Member
    Join Date
    Oct 2006
    Posts
    2

    Compare a string with lines in a file

    I have this textfile with a lot of words in it.
    One word on each line.

    How can I compare a flash string to the lines in the textfile?
    I want to know if the string matches any of the lines in the file.

  2. #2
    Junior Member
    Join Date
    Oct 2006
    Posts
    2
    This is how far I have come. It does´nt work the way I want.
    Can you take a look and see if you know whats wrong?

    Code:
         textfile = new LoadVars; 
         textfile.load("text.txt"); 
         textfile.onLoad = ok; 
    function ok(){ 
         textArray = new Array(); 
         textArray = textfile.words.split('\n'); 
              for( var i=0; i<textArray.length; i++ ){ 
                   if ( thestring == textArray[i] ) trace(textArray[i]); 
              } 
         }
    The file "text.txt" have 1000+ words, only one word per line.
    And "thestring" is a word that I read from a input textfield on the stage.
    Is there a better way to load words than from a txt file?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center