The truncation algorithm simply chops characters until textWidth + 
truncationText.textWidth fits.

You could write a similar algorithm that adds “.” until you reach the desired 
width.  Could be slow though.  There are variants that use binary-subdivision 
to speed things up a bit, but it is still essentially looping.

An alternative would be to always have a row of “.” as wide as the renderer and 
overlay the two text pieces over the row and use some white backgrounds behind 
the text so it covers the “.”  That could be faster, and the “.”would always 
line up in the rows above and below, but the distance between the last char and 
first “.” would vary.

In mx components, there is a Label component and a UITextFIeld that is usually 
used to display text in various components.  In Spark, there is just Label so 
there would be less confusion about which one to use where, especially for less 
tech-savvy folks like skin designers using Flash Catalyst.  Lots of folks use 
mx:Label in item renderers and pay the performance cost and have the same issue 
with styles.  And now that Spark Label is everywhere, if you change its default 
styles the effects show up everywhere.  Which is normally a good thing.  And 
the way to get a subset of Labels to behave differently has not changed.  Use 
CSS via a class selector and stylename, or subclass and use a custom 
type-selector.


On 2/23/10 1:55 PM, "[email protected]" <[email protected]> wrote:






I could really use some help with this one.

I have an item renderer consisting of two labels, positioned horizontally.

I want to fill the distance between them with "....", for example:

Car.........$40,000
House......$400,000

Any ideas how to do this?

Also, there is the caveat that I draw the "..." in a way that matches the "..." 
from Flex truncating the first item.

I am using Spark Label Components, which matters because I can't change the 
truncationText anymore without affecting all Labels in the app (who decided to 
change this on the flex team i have no idea or why!).

Thanks all.






--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui

Reply via email to