Search in Flash

Out of context: Reply #11

  • Started
  • Last post
  • 11 Responses
  • lostnation0

    One last try for good measure. This works with mutliple keywords:

    textfield.prototype.hasKeywords = function(kwords) {
    delete this.results;
    for (i=0; i<arguments.length; i++) {
    if (this.text == arguments[i] || this.text.indexOf(arguments[i]) != '-1') {
    if (this.results == undefined) {
    this.results = new Array();
    }
    this.results.push(arguments[i]+' found at character '+this.findLoc(arguments[i]));
    }
    }
    if (this.results != undefined) {
    trace(this.results);
    return this.results;
    } else {
    trace("no keywords found");
    return false;
    }
    };
    textfield.prototype.findLoc = function(txt) {
    return this.text.indexOf(txt);
    };
    yourTextField.hasKeywords('keywo... 'keyword2');

    ooh...happy weekend!

View thread