篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 Text String Clipper类相关的知识,希望对你有一定的参考价值。
/**
Text String Clipper class
author: Blaine Joubert
version: 0.1
modified: 04/08/2009
Adds a ... to the end of a text string if its too long
To use: Import Class then use
var textClip:TextClipper = new TextClipper (cutOffCharLength, textFieldName, textFieldCharLength, textContent)
*/
package {
import flash.display.*;
import flash.text.*;
public class TextClipper extends MovieClip {
//--------------------------------------
// PUBLIC VARIABLES
//--------------------------------------
public var _cutOffCharLength:int
public var _textFieldName:TextField
public var _textFieldCharLength :int
public var _textContent:String
//--------------------------------------
// CONSTRUCTOR
//--------------------------------------
public function TextClipper(cutOffCharLength:int, textFieldName:TextField, textFieldCharLength:int, textContent:String ):void {
_cutOffCharLength = cutOffCharLength;
_textFieldName = textFieldName;
_textFieldCharLength = textFieldCharLength;
_textContent = textContent;
Init();
}
public function Init():void {
if (_textFieldCharLength >= _cutOffCharLength) {
_textFieldName.replaceText(_cutOffCharLength, _textFieldCharLength, "...");
}else {
_textFieldName.text = _textContent
}
}
}
}
以上是关于ActionScript 3 Text String Clipper类的主要内容,如果未能解决你的问题,请参考以下文章