tags:

views:

42

answers:

2

hi,

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

+1  A: 

substr(startIndex:Number = 0, len:Number = 0x7fffffff):String Returns a substring consisting of the characters that start at the specified startIndex and with a length specified by len.

from HERE

thelost
A: 

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) + '...'
lunixbochs
how can I run full flex code ? I tried label="{bookmarksRepeater.currentItem.name.length <= 60 ? bookmarksRepeater.currentItem.name : bookmarksRepeater.currentItem.name.substr(0, 57) + '...'}" but it gives me this error: The value of attribute "label" must not contain the '<' character.
Patrick
It's XML. Try `<`.
eswald