/ Published in: ActionScript 3
Expand |
Embed | Plain Text
/** 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 } } } }
You need to login to post a comment.
