| 1 |
/*======================================================================*//** |
|---|
| 2 |
* com.emzah.display.ToolTips Class for ActionScript 2.0 |
|---|
| 3 |
* |
|---|
| 4 |
* @author Copyright (c) 2008 gen:emzah.com |
|---|
| 5 |
* @version 0.1 |
|---|
| 6 |
* |
|---|
| 7 |
* @link http://emzah.com |
|---|
| 8 |
* @link http://blg.emzah.com |
|---|
| 9 |
* |
|---|
| 10 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|---|
| 11 |
* you may not use this file except in compliance with the License. |
|---|
| 12 |
* You may obtain a copy of the License at |
|---|
| 13 |
* |
|---|
| 14 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|---|
| 15 |
* |
|---|
| 16 |
* Unless required by applicable law or agreed to in writing, software |
|---|
| 17 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 18 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|---|
| 19 |
* either express or implied. See the License for the specific language |
|---|
| 20 |
* governing permissions and limitations under the License. |
|---|
| 21 |
*//*=======================================================================*/ |
|---|
| 22 |
|
|---|
| 23 |
/** |
|---|
| 24 |
* ToolTips バルーンを表示 |
|---|
| 25 |
* @data 2008/03/14 |
|---|
| 26 |
* @usage |
|---|
| 27 |
* <code> |
|---|
| 28 |
* var tooltips:ToolTips = new ToolTips(this,[hitmc]); |
|---|
| 29 |
* hitmc.tooltipText = "ほげ"; |
|---|
| 30 |
* tooltips.setToolTips(); |
|---|
| 31 |
* var mouseListener:Object = new Object(); |
|---|
| 32 |
* mouseListener.onMouseMove = function() { |
|---|
| 33 |
* tooltips.hitCheck(); |
|---|
| 34 |
* }; |
|---|
| 35 |
* Mouse.addListener(mouseListener); |
|---|
| 36 |
* </code> |
|---|
| 37 |
*/ |
|---|
| 38 |
|
|---|
| 39 |
import com.emzah.display.Shape; |
|---|
| 40 |
|
|---|
| 41 |
class com.emzah.utils.ToolTips { |
|---|
| 42 |
|
|---|
| 43 |
public var toolTips:MovieClip; |
|---|
| 44 |
public var toolTipsBase:MovieClip; |
|---|
| 45 |
public var hitMCArray:Array; |
|---|
| 46 |
public var levelMC:MovieClip; |
|---|
| 47 |
public var fmt:TextFormat; |
|---|
| 48 |
public var boxArray:Array; |
|---|
| 49 |
public var toolTipsBaseColor:String; |
|---|
| 50 |
public var toolTipsBaseAlpha:Number; |
|---|
| 51 |
public var toolTipsBaseLineColor:String; |
|---|
| 52 |
public var toolTipsBaseLineWidth:Number; |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
function ToolTips(levelMC,hitMCArray){ |
|---|
| 56 |
|
|---|
| 57 |
this.levelMC = levelMC; |
|---|
| 58 |
this.hitMCArray = hitMCArray; |
|---|
| 59 |
|
|---|
| 60 |
setBox(); |
|---|
| 61 |
setTipsTextFormat(); |
|---|
| 62 |
|
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
/** |
|---|
| 66 |
* ポップアップをセット |
|---|
| 67 |
*/ |
|---|
| 68 |
public function setToolTips(mc){ |
|---|
| 69 |
|
|---|
| 70 |
var l = this.hitMCArray.length; |
|---|
| 71 |
var hitMCArray = this.hitMCArray; |
|---|
| 72 |
var toolTipsBase = this.toolTipsBase; |
|---|
| 73 |
var hit:Number = 0; |
|---|
| 74 |
var fmt:TextFormat = this.fmt; |
|---|
| 75 |
var boxArray:Array = this.boxArray; |
|---|
| 76 |
|
|---|
| 77 |
this.toolTips = levelMC.createEmptyMovieClip("toolTips",levelMC.getNextHighestDepth()); |
|---|
| 78 |
this.toolTipsBase = toolTips.createEmptyMovieClip("toolTipsBase",toolTips.getNextHighestDepth()); |
|---|
| 79 |
|
|---|
| 80 |
Shape.box(this.toolTipsBase,0,0,200,20,[this.toolTipsBaseLineColor,this.toolTipsBaseLineWidth],[this.toolTipsBaseColor,this.toolTipsBaseAlpha]); |
|---|
| 81 |
|
|---|
| 82 |
this.toolTips.createTextField("txt", 1, 2, 3, 400, 25); |
|---|
| 83 |
this.toolTips._visible = false; |
|---|
| 84 |
|
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
/** |
|---|
| 88 |
* ポップアップの色・線をセット |
|---|
| 89 |
* |
|---|
| 90 |
* <code> |
|---|
| 91 |
* tooltips.setBox(["0x00000CC",2],["0xFF0000",100]); |
|---|
| 92 |
* </code> |
|---|
| 93 |
*/ |
|---|
| 94 |
public function setBox(lineArray:Array,baseArray:Array){ |
|---|
| 95 |
|
|---|
| 96 |
if(lineArray == undefined && baseArray == undefined){ |
|---|
| 97 |
|
|---|
| 98 |
this.toolTipsBaseColor = "0xFFFFCC"; |
|---|
| 99 |
this.toolTipsBaseLineWidth = 1; |
|---|
| 100 |
this.toolTipsBaseLineColor = "0x999999"; |
|---|
| 101 |
this.toolTipsBaseAlpha = 100; |
|---|
| 102 |
|
|---|
| 103 |
}else if(lineArray == undefined){ |
|---|
| 104 |
|
|---|
| 105 |
this.toolTipsBaseLineColor = "0x999999"; |
|---|
| 106 |
this.toolTipsBaseLineWidth = 1; |
|---|
| 107 |
this.toolTipsBaseColor = baseArray[0]; |
|---|
| 108 |
this.toolTipsBaseAlpha = baseArray[1]; |
|---|
| 109 |
|
|---|
| 110 |
}else if(baseArray == undefined){ |
|---|
| 111 |
|
|---|
| 112 |
this.toolTipsBaseLineColor = lineArray[0]; |
|---|
| 113 |
this.toolTipsBaseLineWidth = lineArray[1]; |
|---|
| 114 |
this.toolTipsBaseColor = "0xFFFFCC"; |
|---|
| 115 |
this.toolTipsBaseAlpha = 100; |
|---|
| 116 |
|
|---|
| 117 |
}else{ |
|---|
| 118 |
|
|---|
| 119 |
var array:Array = new Array(); |
|---|
| 120 |
this.toolTipsBaseLineColor = lineArray[0]; |
|---|
| 121 |
this.toolTipsBaseLineWidth = lineArray[1]; |
|---|
| 122 |
this.toolTipsBaseColor = baseArray[0]; |
|---|
| 123 |
this.toolTipsBaseAlpha = baseArray[1]; |
|---|
| 124 |
|
|---|
| 125 |
} |
|---|
| 126 |
} |
|---|
| 127 |
|
|---|
| 128 |
/** |
|---|
| 129 |
* ポップアップの形をセット |
|---|
| 130 |
*/ |
|---|
| 131 |
public function setBoxFormat(boxFormat){ |
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
/** |
|---|
| 135 |
* ポップアップのTextFormatをセット |
|---|
| 136 |
* <code> |
|---|
| 137 |
* var myfmt:TextFormat = new TextFormat(); |
|---|
| 138 |
* myfmt.size = 20; |
|---|
| 139 |
* myfmt.font = "_等幅"; |
|---|
| 140 |
* myfmt.color = 0xFFFFFF; |
|---|
| 141 |
* tooltips.setTipsTextFormat(myfmt); |
|---|
| 142 |
* </code> |
|---|
| 143 |
*/ |
|---|
| 144 |
public function setTipsTextFormat(_fmt){ |
|---|
| 145 |
|
|---|
| 146 |
if(_fmt == undefined || _fmt == null){ |
|---|
| 147 |
|
|---|
| 148 |
var fmt:TextFormat = new TextFormat(); |
|---|
| 149 |
fmt.size = 10; |
|---|
| 150 |
fmt.font = "_等幅"; |
|---|
| 151 |
|
|---|
| 152 |
this.fmt = fmt; |
|---|
| 153 |
|
|---|
| 154 |
}else{ |
|---|
| 155 |
|
|---|
| 156 |
this.fmt = _fmt; |
|---|
| 157 |
|
|---|
| 158 |
} |
|---|
| 159 |
|
|---|
| 160 |
} |
|---|
| 161 |
|
|---|
| 162 |
/** |
|---|
| 163 |
* hitCheck ポップアップ判定 |
|---|
| 164 |
*/ |
|---|
| 165 |
public function hitCheck(){ |
|---|
| 166 |
|
|---|
| 167 |
var l = this.hitMCArray.length; |
|---|
| 168 |
|
|---|
| 169 |
this.toolTips._x = _xmouse +10; |
|---|
| 170 |
this.toolTips._y = _ymouse +10; |
|---|
| 171 |
this.toolTips._visible = false; |
|---|
| 172 |
|
|---|
| 173 |
for(var i = 0 ;i < l; i++){ |
|---|
| 174 |
|
|---|
| 175 |
if(this.hitMCArray[i].hitTest(_xmouse, _ymouse, true)){ |
|---|
| 176 |
|
|---|
| 177 |
var str:String = this.hitMCArray[i].tooltipText; |
|---|
| 178 |
|
|---|
| 179 |
if(str.length != 0 && str != undefined){ |
|---|
| 180 |
this.toolTips.toolTipsBase._width = (str.length * this.fmt.size) + 10; |
|---|
| 181 |
this.toolTips.toolTipsBase._height = (this.fmt.size) + 12; |
|---|
| 182 |
this.toolTips._visible = true; |
|---|
| 183 |
this.toolTips.txt.text = str; |
|---|
| 184 |
this.toolTips.txt.setTextFormat(this.fmt); |
|---|
| 185 |
} |
|---|
| 186 |
} |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
} |
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
} |
|---|