Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to implement Squiggly in textarea

Participant ,
Mar 21, 2013 Mar 21, 2013

Hi,

     I am new to this. I have downloaded the Squiggly package from adobe labs. But i am not sure how to implement it.

Kindly guide me to achieve.

TOPICS
ActionScript
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Mar 21, 2013 Mar 21, 2013

to override the default right-click behaviour with your spell suggestions you have to publish to at least Flash 11 (or higher, google it).

then write a function

stage.addEventListener(MouseEvent.RIGHT_CLICK, showSpellingAlternatives);

and show the  list you get from Squiggly.

Translate
Guru ,
Mar 21, 2013 Mar 21, 2013

Have you considered migrating your project to as3, like discussed in this thread?

1.Copy the downloaded AdobeSpellingEngine.swc in your libs folder

2.Download the ASdocs and extract them

3.Look for the SpellChecker class, it contains an example for Flex that you should have no problem adapting to FlashPro

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 21, 2013 Mar 21, 2013

already i started to migrate teh project to as3

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 21, 2013 Mar 21, 2013

Wise decision 😉

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 21, 2013 Mar 21, 2013

Hi,

     I have used the example code to check. I have a text area in my stage with instance name inp_txt. when i compile i am getting this error. Could you please help me out.

Scene 1, Layer 'Layer 1', Frame 1, Line 21172: Definition mx.controls.textClasses:TextRange could not be found.

This is my code :

import com.adobe.linguistics.spelling.*;

import mx.controls.textClasses.TextRange;

var _newdict:HunspellDictionary = new HunspellDictionary();

var sp:SpellChecker;

function init():void

{

    _newdict.addEventListener(Event.COMPLETE, handleLoadComplete);

    _newdict.load("dictionaries/en_US/en_US.aff", "dictionaries/en_US/en_US.dic");

}

function handleLoadComplete(evt:Event):void

{

    sp = new SpellChecker(_newdict);

}

function checkText():void

{

    var wordPattern:RegExp = /\b\w+\b/;// match next word...

    var inputValue:String = inp_txt.text;

    var offset:int, curPos:int;

    for ( ; ; ) {

    var res:Array = inputValue.match(wordPattern);// lookup word by word....

    if ( res == null )

    {

        break;

    }

    if (! sp.checkWord(res[0]))

    {

        offset = inp_txt.text.length - inputValue.length;

        curPos = inputValue.indexOf(res[0]);

        var currentRange:TextRange = new TextRange(inp_txt,false,offset + curPos,offset + curPos + res[0].length);// mark mispelled word.

        currentRange.color = "red";

    }

    inputValue = inputValue.substr(inputValue.indexOf(res[0]) + res[0].length);

}

}

inp_txt.addEventListener(KeyboardEvent.KEY_UP,handler);

function handler(event:KeyboardEvent)

{

    // if the key is ENTER

    if (event.charCode == 32)

    {

        // your code here

        checkText();

    }

}

init();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 21, 2013 Mar 21, 2013

TextRange is a Flex only class.

from the ASDOCs:

The TextRange class provides properties that select and format a range of text in the Label, Text, TextArea, TextEditor, and RichTextEditor controls.

you should be able to emulate its functionality with the setSelection function

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 21, 2013 Mar 21, 2013

I am getting the selection for the wrong word. But i am not getting any suggesting for spell error.. kindly advise me how to achieve this.

http://labs.adobe.com/technologies/squiggly/demo/

this is my exact request..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 21, 2013 Mar 21, 2013

to override the default right-click behaviour with your spell suggestions you have to publish to at least Flash 11 (or higher, google it).

then write a function

stage.addEventListener(MouseEvent.RIGHT_CLICK, showSpellingAlternatives);

and show the  list you get from Squiggly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 22, 2013 Mar 22, 2013
LATEST

Thanks for your extrodinary support

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines