Flash AS3:在X行处裁剪文本字段内容,添加'';最后
界面中只有三行文本的空间,但内容是外部的和可变的,如果它占用了三行以上的内容,则需要某种“查看全部”按钮功能。我可以考虑这个函数应该是什么样子,但我不太确定在AS3中实现它的最佳方式是什么。类似于(在伪代码中): 。。。正确的?您将如何填写缺少的部分?类似于Flash AS3:在X行处裁剪文本字段内容,添加'';最后,flash,actionscript-3,textfield,utilities,Flash,Actionscript 3,Textfield,Utilities,界面中只有三行文本的空间,但内容是外部的和可变的,如果它占用了三行以上的内容,则需要某种“查看全部”按钮功能。我可以考虑这个函数应该是什么样子,但我不太确定在AS3中实现它的最佳方式是什么。类似于(在伪代码中): 。。。正确的?您将如何填写缺少的部分?类似于 private function cropText(source:TextField, length:int, append:String):TextField { if (source.numLines > length)
private function cropText(source:TextField, length:int, append:String):TextField {
if (source.numLines > length) {
source.text = source.text.substr(0, source.getLineOffset(length) - append.length) + append;
}
return source;
}
private function cropText(source:TextField, length:int, append:String):TextField {
if (source.numLines > length) {
source.text = source.text.substr(0, source.getLineOffset(length) - append.length) + append;
}
return source;
}