Packagenet.guttershark.util.autosuggest
Classpublic class AutoSuggest

The AutoSuggest class provides the search logic needed for an auto suggest, as well as providing you with match data.

The AutoSuggest class searches through the provided a list of terms for a specific search term.

As an example. Assume you had this list of words to search through:

Now assume you started typing "Fl", the AutoSuggest instance would return an array of AutoSuggestMatches. The two that matched were Flash and Flex.

See also

net.guttershark.util.autosuggest.AutoSuggestMatch


Public Properties
 PropertyDefined by
  terms : Array
[write-only] Set the terms to search through.
AutoSuggest
Public Methods
 MethodDefined by
  
AutoSuggest(terms:Array, caseSensitive:Boolean = false)
Constructor for AutoSuggest instances.
AutoSuggest
  
dispose():void
Dispose of internal objects in memory.
AutoSuggest
  
search(term:String, returnLowercaseMatches:Boolean = true):Array
Search through the terms in this auto suggest instance for a particular word or phrase.
AutoSuggest
Property detail
termsproperty
terms:Array  [write-only]

Set the terms to search through.

Implementation
    public function set terms(value:Array):void
Constructor detail
AutoSuggest()constructor
public function AutoSuggest(terms:Array, caseSensitive:Boolean = false)

Constructor for AutoSuggest instances.

Parameters
terms:Array — An array of strings to search through.
 
caseSensitive:Boolean (default = false) — If case sensitivity matters.

Throws
— ArgumentError If the terms array is null.
Method detail
dispose()method
public function dispose():void

Dispose of internal objects in memory.

search()method 
public function search(term:String, returnLowercaseMatches:Boolean = true):Array

Search through the terms in this auto suggest instance for a particular word or phrase.

Example usage:

 
   import net.guttershark.util.autosuggest.AutoSuggest;
   
   var terms:Array = [
     "George Bush", "Chaotmic Matter", "Particle Effects", "Word up",
     "Gangsta", "The Tony Danza Tap Dance Extravaganza", "Good bye",
     "Goodby","Gaa"
   ];
   
   var ast:AutoSuggest = new AutoSuggest(terms,false);
   var a:= ast.search("The Tony",true);
   
   trace(a[0].term);
   trace(a[0].highlightedTerm);
   
   var b:= ast.search("G",true)
   trace(b.length);
   
   for(var i:int = 0; i < b.length; i++)
   {
      trace(b[i].term + " :: " + b[i].highlightedTerm);
   }
   
Parameters
term:String — The term to search for.
 
returnLowercaseMatches:Boolean (default = true) — Return all lowercase matches.

Returns
Array — Array An array of AutoSuggestMatches.

See also

net.guttershark.util.AutoSuggestMatch