Flex SpellChecker embedding instructions

Download Library

Adding library to the project

It is necessary to append the library to work with SpellChecker Flex Application. Using project properties select Flex Build Path section and add the library contained SpellChecker application on Library Path tab.

Application use cases and API

It is necessary to create the main class instance to work with the application. Declare variable of SpellChecker type. Developer can use more than one instance of the class - one for each text input control.

SpellChecker class constructor

The class constructor accepts 3 parameters: 2 mandatory and 1 optional. The first parameter serviceHost is the URL to the service script (e.g. http://www.spellchecker.net/spellcheck2/script/ssrv.cgi). The second parameter is CustomerID string. It is unique for each SpellChecker.net customer. The third parameter is optional. It is UI element (derived from DisplayObject class). This element is used for alignment of SpellChecker window. The window appears in center of whole flex application by default.

Use processText method to show the SpellChecker window. The method accepts the text string for spellchecking.

The application returns a spellchecking result after clicking “Finish Checking” button. The result is spellcheckResult parameter of SPELLCHECK_DONE event. It is necessary to be subscribed to this event before calling processText method.

Code sample with one application instance and two text input controls

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:local="*" 
	       	layout="vertical" horizontalAlign="left" 				 
			creationComplete="init()">
 
   <mx:Script>
      <![CDATA[
	   import com.spellchecker.control.event.SpellCheckerEvent;
	   import com.spellchecker.control.SpellChecker;
 
	   private var _spellchecker 	: SpellChecker;
	   private var _currentTarget	: TextInput;
 
 
	   private function init () : void
	   {
	      _spellchecker = new SpellChecker( 
"http://www.spellchecker.net/spellcheck2/script/ssrv.cgi", "bryRD-Uj4xv3-749Zb2-ywX5w3" );
 
		_spellchecker.addEventListener( SpellCheckerEvent.SPELLCHECK_DONE,
                                             applyChange );
 
	   }
 
	   private function doSpellcheck ( targetTextInput : TextInput ) : void
	   {
	      _currentTarget = targetTextInput;
 
		_spellchecker.processText( _currentTarget.text )
	   }
 
	   private function applyChange ( event:SpellCheckerEvent ) : void
	   {						
	      _currentTarget.text = event.spellcheckResult;
	   }
 
      ]]>
   </mx:Script>
 
   <mx:TextInput id="$someTextInput" />	
   <mx:Button label="Some Button" click="doSpellcheck( $someTextInput )" />
 
   <mx:TextInput id="$someTextInput2" />	
   <mx:Button label="Some Button" click="doSpellcheck( $someTextInput2 )" />
 
</mx:Application>