Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flash AS3:在X行处裁剪文本字段内容,添加'';最后_Flash_Actionscript 3_Textfield_Utilities - Fatal编程技术网

Flash AS3:在X行处裁剪文本字段内容,添加'';最后

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)

界面中只有三行文本的空间,但内容是外部的和可变的,如果它占用了三行以上的内容,则需要某种“查看全部”按钮功能。我可以考虑这个函数应该是什么样子,但我不太确定在AS3中实现它的最佳方式是什么。类似于(在伪代码中):

。。。正确的?您将如何填写缺少的部分?

类似于

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;
}