Adobe Systems, Inc.

GalleryTitle.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.GalleryTitle extends MovieClip { 
00010         
00011         //private member properties
00012 
00013         public var strTextVal:String ="";
00014         public var strUrlVal:String = "";
00015         public var strTagName:String = "textStyle";
00016         public var txtField:TextField;
00017         private var bMouseOver:Boolean;
00018         private var _intervalId:Number;
00019         private var toolTip:MovieClip;
00020         private var _strFieldId:String = "defaultField";
00021 
00022 
00023         //class constructor
00024         public function GalleryTitle(){
00025                 this.createTextField("txtField",1,0,0,10,10);
00026                 this.txtField.html = true;
00027                 this.txtField.borderColor = 0xffffff;
00028                 var styles:TextField.StyleSheet = new TextField.StyleSheet();
00029                 styles.setStyle("textStyle", {
00030                         color:'#ffffff',
00031                         fontFamily:'Myriad Web Pro',
00032                         fontSize:'12', 
00033                         textAlign:'left'
00034                 });
00035                 styles.setStyle("a:link", {
00036                         color:'#ffffff'
00037                 });
00038                 styles.setStyle("a:hover", {
00039                         textDecoration:'underline'
00040                 });
00041                 
00042                 this.txtField.styleSheet = styles;
00043                 
00044                 if(_root.PreviewInLightroom){
00045                         this.onPress = clickField;
00046                 }
00047         }
00048         
00049         public function enableToolTips(){
00050                 
00051                 this.onRollOver = overField;
00052                 this.onRollOut = offField;
00053         }
00054         
00055         
00056         public function setTextValue(strNewVal:String):Void{
00057                 strTextVal = strNewVal;
00058                 if(this.strUrlVal == "")
00059                         txtField.htmlText = "<"+strTagName+">"+strNewVal+"</"+strTagName+">";
00060                 else
00061                         txtField.htmlText = "<"+strTagName+"><a target='_self' href='"+strUrlVal+"'>"+strTextVal+"</a></"+strTagName+">";
00062                         
00063                 
00064         }
00065         
00066         public function addUrlLink(strUrlLink:String):Void{
00067                 this.strUrlVal = strUrlLink;
00068                 txtField.htmlText = "<"+strTagName+"><a target='_self' href='"+strUrlLink+"'>"+strTextVal+"</a></"+strTagName+">";
00069                 
00070         }
00071         
00072         private function clickField():Void{
00073                 var textStyle = this.txtField.styleSheet.getStyle("textStyle")
00074                 
00075                 _root.UIElementClick(_strFieldId,this._x,this._y,this._height,this._width, textStyle.fontFamily, textStyle.fontSize, textStyle.textAlign);
00076         }
00077         
00078         
00079         private function overField():Void{
00080                 this.bMouseOver = true;
00081                 _intervalId = setInterval(this,"showToolTip",1000);
00082         }
00083         
00084         private function offField():Void{
00085                 clearInterval(_intervalId);
00086                 this.bMouseOver = false;
00087                 this._parent.hideToolTip();
00088         }
00089         
00090         private function showToolTip():Void{
00091                 clearInterval(_intervalId);
00092                 this._parent.showToolTip(this.strTextVal,"useMousePos",false);
00093         }
00094         
00095         public function truncateString(limitingw:String,w:Number,h:Number):Void{
00096                 var tempString:String = this.txtField.text;
00097                 switch (limitingw) {
00098                         case "width" :
00099                                 while(txtField.textWidth > w){
00100                                         //remove one char from the temp string
00101                                         tempString = tempString.substring(0,tempString.length-1);
00102                                         txtField.htmlText = "<"+strTagName+">"+tempString+"...</"+strTagName+">";
00103                                         //if only the dots are left, stop truncating
00104                                         if(txtField.text.length <= 4)
00105                                                 break;
00106                                 }
00107                                 break;
00108                         case "height" :
00109                                 
00110                                 while(txtField.textHeight >= h){
00111                                         //remove one char from the temp string
00112                                         tempString = tempString.substring(0,tempString.length-1);
00113                                         txtField.htmlText = "<"+strTagName+">"+tempString+"...</"+strTagName+">";
00114                                         //if only the dots are left, stop truncating
00115                                         if(txtField.text.length <= 4)
00116                                                 break;
00117                                 }
00118                                 while(txtField.textWidth > w){
00119                                         //remove one char from the temp string
00120                                         tempString = tempString.substring(0,tempString.length-1);
00121                                         txtField.htmlText = "<"+strTagName+">"+tempString+"...</"+strTagName+">";
00122                                         //if only the dots are left, stop truncating
00123                                         if(txtField.text.length <= 4)
00124                                                 break;
00125                                 }
00126                                 
00127                                 break;
00128                 }
00129         }
00130         
00131         
00132 }

Copyright © 2006 Adobe Systems Incorporated.

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