使用回车键查找上一个单词边界?

时间:2011-08-04 12:42:03

标签: flex actionscript-3

这段代码效果很好,它可以得到最后一句话,但是当我使用回车键时 它的行为是错误的,并且停止得到最后的单词。当我评论findPreviousWordBoundary行时,它会获取所有文本:

<fx:Script>
    <![CDATA[
        import flashx.textLayout.elements.ParagraphElement;
        protected function togglebutton1_clickHandler(event:MouseEvent):void {
            var urlLoader:URLLoader = new URLLoader();
            var suggestions:Array = new Array();
            var suggested:Array = new Array();
            var textfields:Array = new Array();
            var format:TextFormat = new TextFormat();
            var currentSelection:int = -1;
            mytextflow.addEventListener(KeyboardEvent.KEY_UP, suggest);

            function suggest(event:KeyboardEvent):void {
                suggested = [];
                var activePos:int = mytextflow.selectionActivePosition 
                var curParagraph:ParagraphElement = 
                    mytextflow.textFlow.findLeaf(activePos).getParagraph(); 
                var wordBoundary:int = curParagraph.
                    findPreviousWordBoundary(activePos);
                //var lastword:String = curParagraph.getText(wordBoundary,activePos);
            }               
        }
    ]]>
</fx:Script>

<s:ToggleButton  x="21" y="10" 
    click="togglebutton1_clickHandler(event)"/>
<s:RichEditableText 
    id="mytextflow" 
    x="111" 
    y="43" 
    width="363" 
    height="285" 
    backgroundColor="#C39191"/>             
</s:Application>

0 个答案:

没有答案