00001
00002
00003
00004
00005
00006
00007
00008
00009 class amg.ToolTip extends MovieClip {
00010
00011
00012
00013 public var strTextVal:String;
00014 public var txtField:TextField;
00015 private var backGround:MovieClip;
00016 private var bAllowWrap:Boolean;
00017
00018
00019 public function ToolTip(){
00020 this.backGround = this.createEmptyMovieClip("background",1);
00021
00022 this.createTextField("txtField",2,3,0,100,12);
00023 this.txtField.html = true;
00024 this.txtField.selectable = false;
00025 this.txtField.multiline = false;
00026 this.txtField.embedFonts = false;
00027 this.txtField.wordWrap = false;
00028 this.bAllowWrap = false;
00029 this.onPress = closeToolTip;
00030
00031 var styles:TextField.StyleSheet = new TextField.StyleSheet();
00032 styles.setStyle("toolTip", {
00033 color:'#000000',
00034 fontFamily:'Arial',
00035 fontSize:'10',
00036 textAlign:'left'
00037 });
00038 styles.setStyle("a:link", {
00039 color:'#000000'
00040 });
00041 styles.setStyle("a:hover", {
00042 textDecoration:'underline'
00043 });
00044
00045 this.txtField.styleSheet = styles;
00046 }
00047
00048 private function drawBackground(w:Number,h:Number):Void{
00049 this.backGround.clear();
00050 this.backGround.lineStyle(0, 0x000000, 100, true, "none", "square", "miter", 1);
00051 this.backGround.beginFill(0xFFFFE1,100);
00052 this.backGround.moveTo(0,0);
00053 this.backGround.lineTo(w,0);
00054 this.backGround.lineTo(w,h);
00055 this.backGround.lineTo(0,h);
00056 this.backGround.lineTo(0,0);
00057 this.backGround.endFill();
00058 }
00059
00060
00061 public function setTextValue(strNewVal:String,maxWidth:Number,maxHeight:Number,wrap:Boolean):Void{
00062 this.bAllowWrap = wrap;
00063 strTextVal = strNewVal;
00064 this.txtField.multiline = false;
00065 this.txtField.wordWrap = false;
00066 txtField.htmlText = "<toolTip>"+strNewVal+"</toolTip>";
00067 if(bAllowWrap){
00068 if(txtField.textWidth + 10 > maxWidth){
00069 this.txtField.multiline = true;
00070 this.txtField.wordWrap = true;
00071 txtField._width = maxWidth - 10;
00072 }
00073 else {
00074 this.txtField.multiline = false;
00075 this.txtField.wordWrap = false;
00076 txtField._width = txtField.textWidth + 10;
00077 }
00078 }
00079 else {
00080 if(maxHeight<txtField.textHeight + 10)
00081 this._y -= 40;
00082 if(txtField.textWidth + 10 > maxWidth){
00083 this._x -= txtField.textWidth;
00084 txtField._width = txtField.textWidth + 10;
00085 }
00086 else {
00087 this.txtField.multiline = false;
00088 this.txtField.wordWrap = false;
00089 txtField._width = txtField.textWidth + 10;
00090 }
00091 }
00092
00093
00094 txtField._height = txtField.textHeight + 10;
00095
00096 this.drawBackground(txtField.textWidth + 10,txtField.textHeight+5);
00097 }
00098
00099
00100 private function closeToolTip():Void{
00101 this._visible = false;
00102 }
00103
00104 }