Google Web after-hours

Contador en flash JSFL Traductor
Dificultad

Con un poco de código actionScript podemos crear tooltips similares a los de las páginas HTML.

Función que muestra el tooltip

showToolTip = function (texto) {
	toolTip_mc.texto.text = texto;
	toolTip_mc._x = _xmouse;
	toolTip_mc._y = _ymouse;
	toolTip_mc._visible = true;
	toolTip_mc.startDrag();
};

Función que esconde el toolTip

hideToolTip = function () {
	toolTip_mc._visible = 0;
	toolTip_mc.stopDrag();
};

Formato para el objeto TextField que vamos a crear

formato = new TextFormat();
formato.color = 0xff0000;
formato.font = "verdana";

Creamos un clip de pelí cula.

this.createEmptyMovieClip("toolTip_mc", this.getNextHighestDepth());
this.toolTip_mc._visible = false;

Creamos un campo de texto dentro del clip de pelí cula.

this.toolTip_mc.createTextField("texto", this.getNextHighestDepth(), 10, -15, "", "");
this.toolTip_mc.texto.setNewTextFormat(formato);

Modificamos las propiedades del campo de texto

this.toolTip_mc.texto.border = true;
this.toolTip_mc.texto.borderColor = 0x000000;
this.toolTip_mc.texto.autoSize = true;
this.toolTip_mc.texto.background = true;
this.toolTip_mc.texto.backgroundColor = 0xffffff;

Ejemplo de uso

boton_mc.onRollOver = function() {
	showToolTip("Hola mundo");
};
boton_mc.onRollOut = hideToolTip;

11 Responses to 'ToolTip dinámico'

  1. TheOm3ga Says:

    Yo en cristalab hice un tutorial sobre ello hace tiempo, la dire: http://www.cristalab.com/vertutorial.php?id=55

    El mio se parece más al de windows ajajjaja
    (Joke ;)

  2. tonilopez Says:

    Pues está muy bien, una cosa, esto: selectable = false;

    ¿pa que?

    jua jua te he pillao :P

    Ah! y el onEnterFrame lo podrás evitar con un setInterval.

    saludos!

  3. Diego Lleó Says:

    Está muy bien, muy simple y útil. Me gusta.

  4. keyman Says:

    Una manera rápida y sencilla. Y lo mejor de too dinámico, como a mi me gusta XDD.. mu wueno toni

  5. Raúl Jiménez Says:

    Toni, has visto la clase de etiquetas que he hecho?

    Si quieres ya te la pasare que está muy bien, jeje.

    Un saludo!! ^^

  6. tonilopez Says:

    Gracias Raul, ya me la he bajado.

    Un saludo :)

  7. Galileo Says:

    Esta chulo :)

  8. Galileo Says:

    Raúl, ¿te has fijado en tu blog, que el texto de la derecha “Archivo:” se monta sobre el botón buscar?

  9. Raúl Jiménez Says:

    Pues sí , pero sólo les pasa a los que entran con IE ¬¬ (no deberí as usar eso, caca, XD)

    Intentaré arreglarlo a ver si funciona mejor, pero me lo he estado mirando y no se que está mal todaví a.

    Un saludo!!

  10. alejandro Says:

    a mi me sale esto:
    **Error** Symbol=mc_toolTip, layer=palo izquierda abajo, frame=1:Line 2: Type mismatch in assignment statement: found Number where Boolean is required.
    _visible = 0;

    estoy publicando mi trabajo en flash 6 as2
    funciona el tooltip, pero me fastidia q salga el panel,….porq razon es?

  11. tonilopez Says:

    Hola Alejandro

    Cambia:

    _visible = 0;

    por

    _visible = false

    Saludos