20/08/2008, 10:55
|
| | Fecha de Ingreso: agosto-2002 Ubicación: Monterrey
Mensajes: 82
Antigüedad: 22 años, 3 meses Puntos: 0 | |
Respuesta: class en Flash (donde va?) va el class completo:
class ToolTip {
public var tip:MovieClip;
public var tipMask:MovieClip;
private var tip_txt:TextField;
private var removeInterval:Number;
private var pauseInterval:Number;
public var lineColor:Number = 0x666666;
public var bgColor:Number = 0xFFFFE9;
public var shadowColor:Number = 0x777777;
public var sD:Number = 3; //shadow distance
public var PAUSE_INT:Number = 800; //time until tip shows up
public var REMOVE_INT:Number = 4000; //time that tip stays on
function ToolTip() {
}
public function addTip(words:String):Void {
tip = _root.createEmptyMovieClip("tip", _root.getNextHighestDepth());
tip._x = _root._xmouse;
tip._y = _root._ymouse;
tip.onEnterFrame = function() {
this._x += ((_root._xmouse-this._x-2)*0.2);
this._y += ((_root._ymouse-this._y-5)*0.2);
};
pauseInterval = setInterval(this, "setText", PAUSE_INT, words);
}
private function setText(words:String):Void {
clearInterval(pauseInterval);
//create empty text holder
tip.createTextField("txt", 0, -8, -21, 0, 20);
tip.txt.autoSize = true;
tip.txt.border = false;
tip.txt.selectable = false;
tip.txt.type = "dynamic";
tip.txt.text = words;
//set font style
var myformat:TextFormat = new TextFormat();
myformat.font = "Verdana,Arial";
myformat.size = 10;
tip.txt.setTextFormat(myformat);
var textWidth = tip.txt._width;
drawBubble(textWidth); //now draw bubble
//time to remove tip
removeInterval = setInterval(this, "removeTip", REMOVE_INT);
}
//draw the bg bubble for the text field
private function drawBubble(textWidth:Number):Void {
//get text width from text field
tip.createEmptyMovieClip("outline_mc", -1);
tip.outline_mc.enabled = false;
tip.outline_mc.lineStyle(0, lineColor, 100);
tip.outline_mc.beginFill(bgColor, 100);
tip.outline_mc.moveTo(0, 0);
tip.outline_mc.lineTo(-3, -3);
tip.outline_mc.lineTo(-10, -3);
tip.outline_mc.lineTo(-10, -20);
tip.outline_mc.lineTo(textWidth-6, -20);
tip.outline_mc.lineTo(textWidth-6, -3);
tip.outline_mc.lineTo(3, -3);
tip.outline_mc.lineTo(0, 0);
tip.outline_mc.endFill();
drawShadow(textWidth); //now draw shadow
}
private function drawShadow(textWidth:Number):Void {
tip.createEmptyMovieClip("shadow_mc", -2);
tip.shadow_mc.beginFill(shadowColor, 40);
tip.shadow_mc.moveTo(0+sD, 0+sD);
tip.shadow_mc.lineTo(-3+sD, -3+sD);
tip.shadow_mc.lineTo(-10+sD, -3+sD);
tip.shadow_mc.lineTo(-10+sD, -20+sD);
tip.shadow_mc.lineTo(textWidth-6+sD, -20+sD);
tip.shadow_mc.lineTo(textWidth-6+sD, -3+sD);
tip.shadow_mc.lineTo(3+sD, -3+sD);
tip.shadow_mc.lineTo(0+sD, 0+sD);
tip.shadow_mc.endFill();
}
public function removeTip():Void {
clearInterval(pauseInterval);
clearInterval(removeInterval);
//die();
tip.swapDepths(10005); //some sort of hack found on AS.org
tip.removeMovieClip();
delete this;
}
public function die():Void {
clearInterval(removeInterval);
delete tip;
}
}
__________________ Saludos,
Raziel... :) |