/*======================================================================*//**
* com.emzah.display.ToolTips Class for ActionScript 2.0
*
* @author Copyright (c) 2008 gen:emzah.com
* @version 0.1
*
* @link http://emzah.com
* @link http://blg.emzah.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*//*=======================================================================*/
/**
* ToolTips バルーンを表示
* @data 2008/03/14
* @usage
*
* var tooltips:ToolTips = new ToolTips(this,[hitmc]);
* hitmc.tooltipText = "ほげ";
* tooltips.setToolTips();
* var mouseListener:Object = new Object();
* mouseListener.onMouseMove = function() {
* tooltips.hitCheck();
* };
* Mouse.addListener(mouseListener);
*
*/
import com.emzah.display.Shape;
class com.emzah.utils.ToolTips {
public var toolTips:MovieClip;
public var toolTipsBase:MovieClip;
public var hitMCArray:Array;
public var levelMC:MovieClip;
public var fmt:TextFormat;
public var boxArray:Array;
public var toolTipsBaseColor:String;
public var toolTipsBaseAlpha:Number;
public var toolTipsBaseLineColor:String;
public var toolTipsBaseLineWidth:Number;
function ToolTips(levelMC,hitMCArray){
this.levelMC = levelMC;
this.hitMCArray = hitMCArray;
setBox();
setTipsTextFormat();
}
/**
* ポップアップをセット
*/
public function setToolTips(mc){
var l = this.hitMCArray.length;
var hitMCArray = this.hitMCArray;
var toolTipsBase = this.toolTipsBase;
var hit:Number = 0;
var fmt:TextFormat = this.fmt;
var boxArray:Array = this.boxArray;
this.toolTips = levelMC.createEmptyMovieClip("toolTips",levelMC.getNextHighestDepth());
this.toolTipsBase = toolTips.createEmptyMovieClip("toolTipsBase",toolTips.getNextHighestDepth());
Shape.box(this.toolTipsBase,0,0,200,20,[this.toolTipsBaseLineColor,this.toolTipsBaseLineWidth],[this.toolTipsBaseColor,this.toolTipsBaseAlpha]);
this.toolTips.createTextField("txt", 1, 2, 3, 400, 25);
this.toolTips._visible = false;
}
/**
* ポップアップの色・線をセット
*
*
* tooltips.setBox(["0x00000CC",2],["0xFF0000",100]);
*
*/
public function setBox(lineArray:Array,baseArray:Array){
if(lineArray == undefined && baseArray == undefined){
this.toolTipsBaseColor = "0xFFFFCC";
this.toolTipsBaseLineWidth = 1;
this.toolTipsBaseLineColor = "0x999999";
this.toolTipsBaseAlpha = 100;
}else if(lineArray == undefined){
this.toolTipsBaseLineColor = "0x999999";
this.toolTipsBaseLineWidth = 1;
this.toolTipsBaseColor = baseArray[0];
this.toolTipsBaseAlpha = baseArray[1];
}else if(baseArray == undefined){
this.toolTipsBaseLineColor = lineArray[0];
this.toolTipsBaseLineWidth = lineArray[1];
this.toolTipsBaseColor = "0xFFFFCC";
this.toolTipsBaseAlpha = 100;
}else{
var array:Array = new Array();
this.toolTipsBaseLineColor = lineArray[0];
this.toolTipsBaseLineWidth = lineArray[1];
this.toolTipsBaseColor = baseArray[0];
this.toolTipsBaseAlpha = baseArray[1];
}
}
/**
* ポップアップの形をセット
*/
public function setBoxFormat(boxFormat){
}
/**
* ポップアップのTextFormatをセット
*
* var myfmt:TextFormat = new TextFormat();
* myfmt.size = 20;
* myfmt.font = "_等幅";
* myfmt.color = 0xFFFFFF;
* tooltips.setTipsTextFormat(myfmt);
*
*/
public function setTipsTextFormat(_fmt){
if(_fmt == undefined || _fmt == null){
var fmt:TextFormat = new TextFormat();
fmt.size = 10;
fmt.font = "_等幅";
this.fmt = fmt;
}else{
this.fmt = _fmt;
}
}
/**
* hitCheck ポップアップ判定
*/
public function hitCheck(){
var l = this.hitMCArray.length;
this.toolTips._x = _xmouse +10;
this.toolTips._y = _ymouse +10;
this.toolTips._visible = false;
for(var i = 0 ;i < l; i++){
if(this.hitMCArray[i].hitTest(_xmouse, _ymouse, true)){
var str:String = this.hitMCArray[i].tooltipText;
if(str.length != 0 && str != undefined){
this.toolTips.toolTipsBase._width = (str.length * this.fmt.size) + 10;
this.toolTips.toolTipsBase._height = (this.fmt.size) + 12;
this.toolTips._visible = true;
this.toolTips.txt.text = str;
this.toolTips.txt.setTextFormat(this.fmt);
}
}
}
}
}