Actionscript 3 获取文本区域中插入符号的XY位置

Actionscript 3 获取文本区域中插入符号的XY位置,actionscript-3,apache-flex,textarea,flash-builder,Actionscript 3,Apache Flex,Textarea,Flash Builder,我需要得到文本区域中插入符号的XY位置 我已经找到了一种得到Y的方法,但是我不知道如何得到X,有人能帮我吗 如果有人想知道,我就是这样得到Y的: var textBeforeCaret:String = text.substr(0, caretIndex); var textDump:String = this.text; this.text = textBeforeCaret; this.validateNow(); yVariable = this.textHeight; this.text

我需要得到文本区域中插入符号的XY位置

我已经找到了一种得到Y的方法,但是我不知道如何得到X,有人能帮我吗

如果有人想知道,我就是这样得到Y的:

var textBeforeCaret:String = text.substr(0, caretIndex);
var textDump:String = this.text;
this.text = textBeforeCaret;
this.validateNow();
yVariable = this.textHeight;
this.text = textDump;

在检查了RafH的链接后,我做了以下操作:

var popUpX:int = 0;
var popUpY:int = 0;
if(text.length > 0){

if(caretIndex > 0){
                                if(this.textField.getCharBoundaries(caretIndex -1) != null){
popUpX = this.textField.getCharBoundaries(caretIndex - 1).right;
popUpY = this.textField.getCharBoundaries(caretIndex - 1).bottom;
}
else{
popUpX = 0;
var i:int = 2;
                                    while(this.textField.getCharBoundaries(caretIndex - i) == null && caretIndex - i > -1){
i++;
}
if(caretIndex - i > -1){
popUpY = this.textField.getCharBoundaries(caretIndex - i).bottom + i * 10;
}
else{
popUpY = i * 10;
}
}
}
else{
popUpX = this.textField.getCharBoundaries(caretIndex).right;
popUpY = this.textField.getCharBoundaries(caretIndex).bottom;
}
}
else{
popUpX = 0;
popUpY = 0;
}

它并不完美,但对我来说已经足够好了

你在插入符号之前和/或之后尝试过角色的字符边界吗?问题是,我需要从文本字段的行尾获取子字符串,而不仅仅是在我按ENTER键进入结束插入符号时,这有点问题,因为它没有标记为\r\n