il vostro inutile sborone fagiano ha creato e testato di persona una classe per creare semplici ToolTips personalizzabili nel carattere e nei colori.

Parametri al costruttore:
  • path di utilizzo ( this, _root, _parent, MovieClip, etc. )
  • latenza 0-100 ( ritardo di comparsa scritta )
  • colore testo ( opzionale, DEFAULT: 0x000000 )
  • colore sfondo ( opzionale, DEFAULT: no sfondo )
  • colore bordo ( opzionale, DEFAULT: no bordo )


Parametri al font:
  • font o nome linkage font esportato ( opzional, DEFAULT: Verdana )
  • size della font ( opzional, DEFAULT: 10 )
  • embedFont ( opzional, default: false ) *

    * se il font viene esportato e l' embed e' true l' effetto entra ed esce in dissolvenza, altrimenti entra ed esce di stacco





ESEMPIO:
/**
* Create 2 bottoni, uno con istanza testMovie1 e uno con istanza testMovie2
* Esportate un font con nome linkage "myAliasLinkage"
* scrivete nel keyframe dedicato delle Actions quanto segue
* ( assicuratevi di avere settato il classpath o di avere
* il file ToolTip.as nella stessa dir )
*/
var myTT:ToolTip = new ToolTip( this, 30, 0x000000, 0xFAFADB, 0x000000 );
myTT.setFont( "myAliasLinkage", 10, true );
myTT.setLabel( testMovie1, "label button 1" );
myTT.setLabel( testMovie2, "label button 2" );
/**
* Testate il filmato, se tutto e' OK dopo una permanenza
* di 600 millesimi ( 30 * 20 <-- intervallo interno di controllo )
* dovreste vedere la vostra ToolTip con la relativa info
*/




ToolTip.as
codice:
/**
 * Class ToolTip :: ToolTip.as :: by [ andr3a ]
 * Create one or more tooltips for your MovieClips, Buttons and other object
 * without modify or implement Button's statements such onPress, OnRelease
 * or other events.
 * .
 * EXAMPLE:
 * var myTT:ToolTip = new ToolTip( this, 30, 0x000000, 0xFAFADB, 0x000000 );
 * myTT.setFont( "myAliasLinkage", 10, true );
 * myTT.setLabel( testMovie1, "my label" );
 * myTT.setLabel( testMovie2, "mytest2" );
 *
 * @version	ActionScript 2.0 class file
 * @author	Andrea Giammarchi
 * @date	05/01/2004
 * @lastMod	17/02/2004 02:50
 * @site	http://www.3site.it/
 */
class ToolTip {
	private var TT_textFormat:TextFormat;
	private var TT_graphic:Object;
	private var TT_absolutePath:Object;
	private var TT_embed:Boolean;
	private var TT_fontColor:Number, TT_borderColor:Number, TT_backgroundColor:Number, TT_showCounter:Number;
	/**
	 * Public constructor
	 * var myToolTip:ToolTip = new ToolTip( path [ latency, [ fontColor, [ backgroundColor, [ borderColor ]]]] );
	 *
	 * @param	Object	path where tooltip will be created
	 *					Example: _root, this, MovieClip, etc.
	 * @param	Number	latency before show ToolTip( 0 - 100 ) DEFAULT: 0
	 * @param	Number	font color ( DEFAULT: 0x000000 )
	 * @param	Number	background color
	 * @param	Number	border color
	 */
	function ToolTip( TT_absolutePath:Object, TT_showCounter:Number, TT_fontColor:Number, TT_backgroundColor:Number, TT_borderColor:Number ) {
		this.TT_absolutePath = TT_absolutePath;
		this.TT_fontColor = TT_fontColor;
		this.TT_borderColor = TT_borderColor;
		this.TT_backgroundColor = TT_backgroundColor;
		this.TT_showCounter = Math.abs( TT_showCounter );
		TT_embed = new Boolean( false );
		TT_textFormat = new TextFormat();
		TT_textFormat.font = "Verdana";
		TT_textFormat.size = 10;
		TT_textFormat.leftMargin = 2;
		TT_textFormat.rightMargin = 2;
		var maxDepht:Number = new Number( TT_absolutePath.getNextHighestDepth() );
		var remName:String = new String( "TT_object_" + maxDepht );
		TT_absolutePath.createEmptyMovieClip( remName, maxDepht );
		TT_graphic = new Object( _root[remName] );
		TT_graphic.createTextField( "TT_label" , TT_absolutePath.getNextHighestDepth() , 0 , 0 , 1 , 1 );
		labelSetup( TT_graphic["TT_label"], TT_fontColor, TT_backgroundColor, TT_borderColor );
		TT_graphic._visible = false;
	}
	/**
	 * Public method
	 * myToolTip.setLabel( TT_movie:Object, TT_label:String );
	 *
	 * @param	Object	MovieClip, Button or other to apply ToolTip
	 * @param	String	String to show on ToolTip
	 * @return	Void
	 */
	public function setLabel( TT_movie:Object, TT_label:String ):Void {
		var maxDepht:Number = new Number( TT_absolutePath.getNextHighestDepth() );
		var remName:String = new String( "TT_object_" + maxDepht );
		TT_graphic.duplicateMovieClip( remName, maxDepht );
		TT_absolutePath[remName].createTextField( "TT_label" , TT_absolutePath.getNextHighestDepth() , 0 , 0 , 1 , 1 );
		labelSetup( TT_absolutePath[remName]["TT_label"], TT_fontColor, TT_backgroundColor, TT_borderColor );
		TT_absolutePath[remName].TT_label.htmlText = TT_label + " ";
		TT_absolutePath[remName].TT_label.setTextFormat( TT_textFormat );
		TT_absolutePath[remName]._alpha = 0;
		TT_absolutePath[remName].__ToolTipInterval = setInterval( this.manageLabel, 20, TT_movie, TT_absolutePath[remName], TT_absolutePath, TT_showCounter );
	}
	/**
	 * Public method
	 * myToolTip.setFont( TT_textFormat:String[, TT_fontsize:Number[, TT_embed:Boolean ]] );
	 *
	 * @param	String	font's linkage or font name
	 * @param	Number	font size ( DEFAULT: default flash choice )
	 * @param	Boolean	embedFont ( DEFAULT: false )
	 * @return	Void
	 */
	public function setFont( TT_textFormat:String, TT_fontsize:Number, TT_embed:Boolean ):Void {
		this.TT_textFormat.font = TT_textFormat;
		if( TT_fontsize != undefined ) {
			this.TT_textFormat.size = TT_fontsize;
		}
		if( TT_embed == true ) {
			this.TT_embed = true;
		}
		else {
			this.TT_embed = false;
		}
		TT_graphic.TT_label.setTextFormat( this.TT_textFormat );
	}
	private function labelSetup( myLabel:Object, TT_fontColor:Number, TT_backgroundColor:Number, TT_borderColor:Number ):Void {
		if( TT_fontColor == undefined ) {
			TT_fontColor = 0x000000;
		}
		if( TT_backgroundColor != undefined ) {
			myLabel.background = true;
			myLabel.backgroundColor = TT_backgroundColor;
		}
		if( TT_borderColor != undefined ) {
			myLabel.border = true;
			myLabel.borderColor = TT_borderColor;
		}
		myLabel.autoSize = true;
		myLabel.multiline = true;
		myLabel.selectable = false;
		myLabel.textColor = TT_fontColor;
		myLabel.embedFonts = TT_embed;
	}
	private function manageLabel( TT_movie:Object, TT_graphic:Object, TT_absolutePath:Object, TT_showCounter:Number ):Void {
		if( TT_movie.hitTest( _root._xmouse, _root._ymouse ) ) {
			var maxDepth:Number = new Number( TT_absolutePath.getNextHighestDepth() );
			if( TT_graphic.getDepth() != ( maxDepth - 1 ) ) {
				TT_graphic.swapDepths( ( maxDepth - 1 ) );
			}
			if( TT_graphic.restarted == TT_showCounter ) {
				if( TT_graphic._visible == false ) {
					TT_graphic._visible = true;
				}
				if( TT_graphic._alpha < 100 ) {
					TT_graphic._alpha += 10;
				}
				else if( TT_graphic._alpha != 100 ){
					TT_graphic._alpha = 100;
				}
			}
			else {
				if( TT_graphic.restarted == undefined ) {
					TT_graphic.restarted = 0;
				}
				TT_graphic.restarted++;
			}
			var maxWidth:Number = new Number( _root._xmouse + 20 + TT_graphic._width );
			var maxHeight:Number = new Number( _root._ymouse + 20 + TT_graphic._height );
			if( ( maxWidth > Stage.width ) || ( maxHeight > Stage.height ) ) {
				if( maxWidth > Stage.width && maxHeight > Stage.height ) {
					TT_graphic._x = Stage.width - TT_graphic._width;
					TT_graphic._y = Stage.height - TT_graphic._height;
				}
				else if( maxWidth > Stage.width && maxHeight < Stage.height ) {
					TT_graphic._x = Stage.width - TT_graphic._width;
					TT_graphic._y = _root._ymouse + 20;
				}
				else if( maxWidth < Stage.width && maxHeight > Stage.height ) {
					TT_graphic._y = Stage.height - TT_graphic._height;
					TT_graphic._x = _root._xmouse + 20;
				}
			}
			else {
				TT_graphic._x = _root._xmouse + 20;
				TT_graphic._y = _root._ymouse + 20;
			}
		}
		else {
			if( TT_graphic._alpha <= 0 ) {
				if( TT_graphic._visible == true ) {
					TT_graphic._visible = false;
					TT_graphic._alpha = 0;
					TT_graphic.restarted = 0;
				}
			}
			else {
				TT_graphic._alpha -= 10;
			}
		}
	}
}
Pareri, critiche e consigli sono bene accetti



[editato]
credo che a flash-mx.it manchi una sezione dedicata alla raccolta classi in AS1/2