Adobe Systems, Inc.

GalleryTextField.as

Go to the documentation of this file.
00001 /****************************************
00002 ** Copyright 2005-2006 Adobe Systems Incorporated
00003 ** Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004 ** or a copy at http://opensource.adobe.com/licenses.html)
00005 **
00006 ** GalleryTextField Class 
00007 ****************************************/
00008 
00009 class amg.GalleryTextField extends MovieClip { 
00010         
00011         //private member properties
00012 
00013         public var strTextVal:String;
00014         public var strTagName:String = "textStyle";
00015         public var txtField:TextField;
00016         private var bMouseOver:Boolean;
00017         private var _intervalId:Number;
00018         private var toolTip:MovieClip;
00019 
00020 
00021         //class constructor
00022         public function GalleryTextField(){
00023                 this.createTextField("txtfield",1,0,0,10,10);
00024                 this.txtField.html = true;
00025                 this.txtField.borderColor = 0xffffff;
00026                 //this.useHandCursor = false;
00027                 this.onRollOver = overField;
00028                 this.onRollOut = offField;
00029                                 
00030                 var styles:TextField.StyleSheet = new TextField.StyleSheet();
00031                 styles.setStyle("textStyle", {
00032                         color:'#ffffff',
00033                         fontFamily:'Myriad Web Pro',
00034                         fontSize:'12', 
00035                         textAlign:'left'
00036                 });
00037                 styles.setStyle("a:link", {
00038                         color:'#ffffff'
00039                 });
00040                 styles.setStyle("a:hover", {
00041                         textDecoration:'underline'
00042                 });
00043                 
00044                 this.txtField.styleSheet = styles;
00045         }
00046         
00047         
00048         public function setTextValue(strNewVal:String):Void{
00049                 strTextVal = strNewVal;
00050                 txtField.htmlText = "<"+strTagName+">"+strNewVal+"</"+strTagName+">";
00051         }
00052         
00053         private function overField():Void{
00054                 this.bMouseOver = true;
00055                 _intervalId = setInterval(this,"showToolTip",1000);
00056         }
00057         
00058         private function offField():Void{
00059                 clearInterval(_intervalId);
00060                 this.bMouseOver = false;
00061                 this._parent.hideToolTip();
00062         }
00063         
00064         private function showToolTip():Void{
00065                 clearInterval(_intervalId);
00066                 this._parent.showToolTip(this.strTextVal,"useMousePos",false);
00067         }
00068         
00069         public function truncateString(limitingw:String,w:Number,h:Number):Void{
00070                 var tempString:String = this.txtField.text;
00071                 switch (limitingw) {
00072                         case "width" :
00073                                 while(txtField.textWidth > w){
00074                                         //remove one char from the temp string
00075                                         tempString = tempString.substring(0,tempString.length-1);
00076                                         txtField.htmlText = "<"+strTagName+">"+tempString+"...</"+strTagName+">";
00077                                         //if only the dots are left, stop truncating
00078                                         if(txtField.text.length <= 4)
00079                                                 break;
00080                                 }
00081                                 break;
00082                         case "height" :
00083                                 
00084                                 while(txtField.textHeight >= h){
00085                                         //remove one char from the temp string
00086                                         tempString = tempString.substring(0,tempString.length-1);
00087                                         txtField.htmlText = "<"+strTagName+">"+tempString+"...</"+strTagName+">";
00088                                         //if only the dots are left, stop truncating
00089                                         if(txtField.text.length <= 4)
00090                                                 break;
00091                                 }
00092                                 while(txtField.textWidth > w){
00093                                         //remove one char from the temp string
00094                                         tempString = tempString.substring(0,tempString.length-1);
00095                                         txtField.htmlText = "<"+strTagName+">"+tempString+"...</"+strTagName+">";
00096                                         //if only the dots are left, stop truncating
00097                                         if(txtField.text.length <= 4)
00098                                                 break;
00099                                 }
00100                                 
00101                                 break;
00102                 }
00103         }
00104         
00105         
00106 }

Copyright © 2006 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.