ActionScript Spellchecker for Flash Textfields (with source code and example)
Finally I had the time to add the missing features to our Spellchecker class v01.
You can now right-click the misspelled words and get suggestions from the loaded dictionary in the context-menu.
Version 2 also improves the performance when checking really long textfields because we only check the visible part of the text. So as long as your textfield doesn’t have 3000 visible lines of text, it’ll work just fine.
So again, this is ActionScript-only spellchecking for FlashPlayer 9. No Flex required (compared to Adobe’s version).
The Apdev Spellchecker is built on top of Adobe’s “Squiggly“, which they released earlier.
Get our class here: ApdevSpellChecker.as
And the required classes from Adobe here: http://labs.adobe.com/downloads/squiggly.html
*Small update* Example for TextField in Flash CS4:
apdev-spellchecker-example-cs4.zip
Hope this helps anybody …
Cheers
11 Trackbacks
-
October 21st, 2009 / 14:23
-
October 23rd, 2009 / 17:17
-
February 21st, 2010 / 16:21
-
March 6th, 2010 / 08:35
-
May 16th, 2010 / 17:23
-
July 15th, 2010 / 07:03
-
August 15th, 2010 / 09:07
-
August 19th, 2010 / 02:52
-
September 20th, 2010 / 07:21
-
October 29th, 2010 / 06:00
-
December 13th, 2010 / 11:14
23 Comments
-
Hey man great job on this. When I first tried it I couldn’t get it to work. Then I removed the “true” values to the “useWeakReference” parameters in your event listeners. That worked. Has caused problems for me in the past with other projects. Depends on the OS, but I have seen listeners get removed with a weak reference. So I have avoided it. I would also include a destroy() method to clear out all listeners, timers, and objects to dispose of the instance. Again, great work and a very useful class.
-
There are some people on the Adobe forums looking for something like this.
Do you want to let them know about it?http://forums.adobe.com/message/2331150?tstart=0#2331150
-
This is great, and its exactly what I’m looking for, however my flash knowledge is limited.
Would you be so kind as to point me in the right direction for implementing something like this into my website (spell checking on text areas)
I know a little flash, but I’m not so schooled in on the packages and how to include them
thanks very much
-
Hi Phil,
It looks like Adobe is no longer distributing the
com.adobe.linguistics.spelling.SpellChecker;
com.adobe.linguistics.spelling.SpellingDictionary;classes in their squiggly download – you would not happen to have them – you are probably not supposed to post them but perhaps you could send them to me…
Thanks.
-
OK, I have set the External Library Path to include the AdobeSpellingEngine.swc BUT I get an error “VerifyError: Error #1014: Class com.adobe.linguistics.spelling::SpellingDictionary could not be found.” The “ApdevSpellChecker.as” file has reference to “import com.adobe.linguistics.spelling.SpellChecker;” which it cannot seem to find…
Please help – your solution is brilliant but I just can’t seem to make it Publish on my end…
-
Figured out that with the newest Squigly package there are several .swc’s now and I included all three and that did the trick – however – now there are several new issues – I’m looking into it…
If you know something I don’t I’d love to find out – thanks much
-
I am emailing you a quick screen cap – PLEASE – I hope you don’t mind an email – thank you.
-
YES THAT WAS IT – IT WORKS!!!!!!
Now – question – may I please include this code in an Open Source project I working on?
Thanks so much really!
-
Hi,
Trying to get your code to work but I get the following two errors. Is there an updated version of the source? Thanks for your help.
Line 84 – 1136: Incorrect number of arguments. Expected 1.
-
I noticed you aren’t taking into account fields with horizontal scrolling..
So i took the liberty and fixed the code so that it will not draw the dots if the word is not visible horizontally and it will always draw the dots in the correct spot if the text is scrolling horizontally aswell.cheers
updated code:
// get vals for drawing highlight
var x1:int = rect1.x – _txt.scrollH;// take the horizontal scroll into account
var x2:int = (rect2.x + rect2.width – _txt.scrollH);
var y1:int = rect1.y + metrics.ascent + 2;// if half the word is outside of the textfield cause of scroll only draw what is visible
var w:Number = Math.max(0,Math.min((x2 – x1), _txt.width – x1)) -
I also noticed a problem when you allow multiline textfields and someone has hit the “ENTER” key to move down to a new paragraph and they miss spell the first word at the last line of the textfield..
here’s the fix
var begin:int = inputValue.lastIndexOf(” “,index);
if (begin >= 0) {
inputValue = inputValue.substr(begin + 1);
}else if(begin == -1){ // if we can’t find a word then check the first Char in the paragraph
begin = _txt.getFirstCharInParagraph(index);
inputValue = inputValue.substr(begin);
} -
If anyone would like to help support highlighting words that wrap two lines let me know.
I’m working on it, but not sure how soon i can have it working.Cheers
-
Any spanish diccionari or é á ó acept

