Well hello,
I had a huge fight with this issue today (3h), which is way too much for a little issue as this. Anyway, none of the above tips solved my problem. I tried it all. I ended up doing my own class, which extends the mx.controls.Label class. The implementation is below. Feel free to use it in your projects. Please note that you should disable the truncateToFit in your mxml when using this one. Else the "null" string will be appended to your text and no truncation will be made.
Code:
package com.feijk.UI{
import mx.controls.Label;
/**
* An extension for mx.controls.Label to truncate the text and show
* a tooltip with the full-length content. This sub-class is meant to be
* used when the regular truncateToFit does result in a "null" appendix
* on the string instead of the "...". In order for this to work, I used
* the following parameters in my mxml:
*
* - truncateToFit = false
* - maxWidth = set
* - width = set
*
*
* @author Tomi Niittumäki // Feijk Industries 2010
* @NOTE: Feel free to use! :)
*/
public class FLabel extends Label{
// define the truncation indicator eg. ...(more) etc.
private const TRUNCATION_INDICATOR:String = new String("...");
/**
* Constructor
*/
public function FLabel(){
super();
}
/**
* The overriding method, which forces the textField to truncate
* its content with the method truncateToFit(truncationIndicator:String)
* and then supers the tooltip to be the original full-length text.
*/
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void{
super.updateDisplayList(unscaledWidth, unscaledHeight);
//trace("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!: "+textField.text);
textField.truncateToFit(TRUNCATION_INDICATOR);
super.toolTip = text;
}
}
}