Flash AS3:在 X 行处裁剪 TextField 内容,添加 '...'在最后
界面中只能容纳三行文本,但内容是外部的且可变的,如果它最终占用超过三行,则需要某种“查看全部”按钮功能。我可以考虑一下该函数需要是什么样子,但我不太确定在 AS3 中实现它的最佳方法是什么。类似于(伪代码):
function cropText(source:TextField, length:int, append:String):TextField{
if(source.lineCount > length){
source.text = // magic function that retuns the first length lines,
// minus append.length characters, with the append value tacked onto the end
}
return source;
}
...对吗?你将如何填补缺失的部分?
There's only room for three lines of text in the interface, but the content is external and variable, and if it ends up taking up more than three lines, there needs to be some sort of 'view all' button functionality. I can kind of think about what that function needs to look like, but I'm not quite sure what the best way to do it in AS3 would be. Something like (in pseudo code):
function cropText(source:TextField, length:int, append:String):TextField{
if(source.lineCount > length){
source.text = // magic function that retuns the first length lines,
// minus append.length characters, with the append value tacked onto the end
}
return source;
}
... right? How would you fill in the missing bit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像...
Something like...