Spell checking in AIR, Flash, and Flex!

If you’ve created an AIR, Flash, or Flex app and dealt with text and user input, you’ve probably looked around for a spell checking solution. There have been some great third-party spell checkers for some time now, with the widest-adopted perhaps being Grant Skinner’s Spelling Plus Library.

Today, however, you can use a spell checking engine called “Squiggly,” released by Adobe and available for free on Adobe Labs! It’s important to note that Squiggly is a preliminary release and is officially unsupported. If you need support or a commercial solution, I recommend checking out Grant Skinner’s SPL.

Squiggly works with AIR, Flex, or pure AS3 apps.
You can see a live demo here.

Using it in your project is quite easy, and requires two things:

  • A compiled dictionary (usa.zwl is included)
  • The AdobeSpelling.swc library

The dictionary: You have two choices. You can either use the English dictionary that ships with Squiggly, or use the DictionaryGenerator.air utility to compile your own from a word list. Note that the spell checking heuristics used to determine alternate words is currently based on English phonological rules…meaning that if you pick a non-English dictionary, the suggestions won’t work. Multi-lingual support is planned for future releases. In either case, take the dictionary.zwl and put it in your application path. For example, in a folder called “assets.”
The library: Place AdobeSpelling.swc in your project’s libs folder, or be sure to append its location to the library path.

You can now call the Squiggly APIs from your application.
If you want to create a spell-checking enabled Halo TextArea or RichText, use the included SpellUI.enableSpelling function, like so:

If you’re not using Flex or you’re designing your own components, you can call the underlying engine by creating a SpellingDictionary and SpellChecker object. To check a given word, for example:

private var _newdict:SpellingDictionary = new SpellingDictionary();
private var sp:SpellChecker= new SpellChecker("en");

private function init():void
_newdict.addEventListener(Event.COMPLETE, handleLoadComplete);
var myURL:URLRequest = new URLRequest("assets/usa.zwl");
private function handleLoadComplete(evt:Event):void

private function checkWord(var someWord:String):void
var correct:Boolean = sp.checkWord(someWord);
if( correct )
trace("Correctly spelled");
// ...
trace("Incorrectly spelled");
// ...

Note that loading the usa.zwl dictionary is an asynchronous event, and is accomplished by using a URLRequest and waiting for Event.COMPLETE to be dispatched.

Squiggly is highly optimized and very fast, and future versions will only improve upon this beta. Please try it out and post your comments or problems in the forums, which I and other Adobe employees will be monitoring.

Squiggly is available here: http://labs.adobe.com/technologies/squiggly/.

5 Responses to Spell checking in AIR, Flash, and Flex!

  1. Brett Walker says:

    Thanks for the clarification re: pure AS3 projects. The Labs page made it sound like this library only worked with Flex text controls. Looking forward to checking it out!

  2. Apphacker says:

    Does it work with AJAX based air apps too?

  3. NateJC says:

    This is fantastic!! Thanks so much to Adobe for this great contribution!

  4. hi daniel.i already built a small example using “normal” as3 TextFields but unfortunately there are some things that are not working with the current version. e.g. the SpellingDictionary’s Event.COMPLETE you are mentioning: it’s never fired, one can’t even add an eventlistener to the object :(so … i don’t know … maybe you have to update the sources/swc or the ASDocs – one is definitely wrong.earlier i read the post by grant skinnerhttp://www.gskinner.com/blog/archives/2009/09/some_thoughts_o.htmland i’m a bit torn between the things he talks about. but i think it’s good for us smaller developers to get access to a spell checking engine that’s not as expensive as SPL. so thank you adobe … but you still need to work it … a bit :)cheers

  5. Zanpher says:

    Yeah, we’ve been looking for a spell checker, but cannot afford to be testers. This is why Squiggly is a no go. We’ll have to look at paying $2k for Skinners …