Packagegs.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 auto suggest instance would return an array of AutoSuggestMatch instances; the two that matched were "Flash" and "Flex".

See also

gs.util.autosuggest.AutoSuggestMatch


Public Properties
 PropertyDefined by
  terms : Array
The terms to search through.
AutoSuggest
Public Methods
 MethodDefined by
  
AutoSuggest(terms:Array)
Constructor for AutoSuggest instances.
AutoSuggest
  
dispose():void
Dispose of this auto suggest instance.
AutoSuggest
  
search(str:String, caseSensitive:Boolean = false, matchAnywhere:Boolean = false, returnLowercaseMatches:Boolean = true):Array
Search for a string.
AutoSuggest
Property detail
termsproperty
terms:Array  [read-write]

The terms to search through.

Implementation
    public function get terms():Array
    public function set terms(value:Array):void
Constructor detail
AutoSuggest()constructor
public function AutoSuggest(terms:Array)

Constructor for AutoSuggest instances.

Parameters
terms:Array — An array of strings to search through.
Method detail
dispose()method
public function dispose():void

Dispose of this auto suggest instance.

search()method 
public function search(str:String, caseSensitive:Boolean = false, matchAnywhere:Boolean = false, returnLowercaseMatches:Boolean = true):Array

Search for a string.

Example usage:

 
   import gs.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");
   
   trace(a[0].term);
   trace(a[0].highlightedTerm);
   
   var b:ast.search("G",true)
   trace(b.length);
   
   var i:int=0;
   var l:int=b.length;
   for(;i<l;i++)
   {
      trace(b[i].term + " :: " + b[i].highlightedTerm);
   }
   
Parameters
str:String — The string to search for.
 
caseSensitive:Boolean (default = false) — Whether or not the search is case sensitive.
 
matchAnywhere:Boolean (default = false) — Whether or not the search string has to be matched form the beginnging (^) of the string, or can the search string be located anywhere in the string and still be considered a match.
 
returnLowercaseMatches:Boolean (default = true) — Whether or not to return the matches as all lowercase strings.

Returns
Array