ActionScript 3 Text String Clipper类

Posted

tags:

篇首语:本文由小常识网(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类的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3.0 - 否则如果是文本字段的条件

TextManager ActionScript 3.0类

Actionscript 3:将类作为参数传递

[ActionScript 3.0] 两个AIR之间的通信示例LocalConnection

actionscript3 计算器声音播放

需要帮助修复代码以将文本框中的值转换为 ActionScript 3 中的变量