# Efficient text truncation?

**URL:** https://forum.kirupa.com/t/efficient-text-truncation/240179
**Category:** flash
**Created:** [September 30, 2007, 2:16pm UTC](https://forum.kirupa.com/t/efficient-text-truncation/240179 "2007-09-30T14:16:16Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)
#### Post date: [September 30, 2007, 2:16pm UTC](https://forum.kirupa.com/t/efficient-text-truncation/240179/1 "2007-09-30T14:16:16Z")

</div>

Ok, so I need to truncate my text to a **width** , not an **amount of characters**. I have a working method, but it’s too slow. After text is truncated I want to append three dots ("…") to it.  
For this I have up to 16 movie clips with up to 3 fields in each that need truncating. So as you can see 3 x 16 = 48 \* # of excess characters; Potentially VERY slow.

My current code is:

```auto
mc.displaySongT.text = mc.song;
 altered = false;
 while (mc.displaySongT.textWidth>82) {
  mc.displaySongT.text = mc.displaySongT.text.slice(0, mc.displaySongT.text.length-1);
  altered = true;
 }
 mc.displaySongT.text = mc.displaySongT.text+(altered ? "..." : "");

```

I could probably come up with another method myself, but I don’t really have the time.  
Any help appreciated.  
Nathan.
