Reputation: 64854
what's the easiest way to cut string in Flex ? I mean, I have a sequence of urls, I want them at most 60 characters length. If they are longer they should be cut and "..." should be added at the end.
<mx:LinkButton label="{bookmarksRepeater.currentItem.name}" click="navigateToURL(new URLRequest(event.currentTarget.label.toString()))" />
thanks
Upvotes: 0
Views: 577
Reputation: 22415
if you can run full flex code in the label="" section, perhaps set the label to this: it's a conditional statement: if the name length is less than or equal to 60, just use the name, otherwise use the first 57 characters of the name and '...'
bookmarksRepeater.currentItem.name.length <= 60 ? bookmarksRepeater.currentItem.name : bookmarksRepeater.currentItem.name.substr(0, 57) + '...'
Upvotes: 1