A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: How Can I check if any string of an Array is matched?

  1. #1
    Senior Member
    Join Date
    Aug 2001
    Location
    Seattle, WA
    Posts
    180

    How Can I check if any string of an Array is matched?

    Hello,

    I am looking for a way to check if any sting of the Array is matched to the string that in the TextField. In the code it should be something like that:

    Code:
    var TestString:Array = new Array ("chicken", "cat", "dog");
    
    function LookStringArray(){			
          if  (TestArrayTextfield_txt.text  ==  (anyString.TestString)){
    		StringExist = true;
    		trace (StringExist);	
          }  
    }

    Please let me know what will be the best approach. Thank you in advance.
    Best regards
    Vlad,

  2. #2
    newb of many sorts Ralgoth's Avatar
    Join Date
    Apr 2002
    Posts
    466
    Code:
    var index:int = TestString.indexOf(TestArrayTextfield_txt.text);
    
    if(index>=0){
         trace('match at '+index);
    } else {
         trace('no match');
    }
    Search first, asked questions later.

  3. #3
    Senior Member
    Join Date
    Aug 2001
    Location
    Seattle, WA
    Posts
    180
    Thank you. I will try that.
    Best regards
    Vlad,

Tags for this Thread

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