AS2.0下的ToolTips(工具提示)

本脚本适用于Flash 8.0(AS2)

将下面文件保存成:ToolTips.as

import Shape;
class 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;
		
	}
	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){
	}
	public function setTipsTextFormat(_fmt){
		
		if(_fmt == undefined || _fmt == null){
		
			var fmt:TextFormat = new TextFormat();
			fmt.size = 12;
			fmt.font = "宋体";
			
			this.fmt = fmt;
			
		}else{
			
			this.fmt = _fmt;
			
		}

	}
	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);
				}
			}
		}
		
	}
}

将下面脚本保存成:Shape.as

class Shape {
    public static function line(mc :MovieClip,
                                x1 :Number,
                                y1 :Number,
                                x2 :Number,
                                y2 :Number,
                                line:Array) : Void {
        if(line[1] == undefined){line[1] = 1;}
        if(line[0] == undefined){line[0] = 0x000000;}
        if (line[1] == 0) {
            mc.lineStyle();
        }else{
            mc.lineStyle(line[1],line[0]);
        }
        mc.beginFill();
        mc.moveTo(x1, y1);
        mc.lineTo(x2, y2);
        mc.lineTo(x1, y1);
        mc.endFill();
    }
    public static function box(mc:MovieClip,
                               x1 :Number,
                               y1 :Number,
                               width :Number,
                               hight :Number,
                               line :Array,
                               base :Array) : Void {
                               
        if(line[1] == undefined){line[1] = 1 }                       
        if(line[0] == undefined){line[0] = 0x000000;}

        if (line[0] == 0) {
            mc.lineStyle();
        }else{
            mc.lineStyle(line[1],line[0]);
        }
        if(base[0] == undefined || base[0]  == null){
        	mc.beginFill();
        }else{
        	if(base.length > 2){
	        	mc.beginGradientFill(base[0],base[1],base[2],base[3],base[4]);
        	}else{
        	
        		mc.beginFill(Number(base[0]),Number(base[1]));
        	}

        }
       
        mc.moveTo(x1, y1);
        mc.lineTo(x1 + width, y1);
        mc.lineTo(x1 + width, y1 + hight);
        mc.lineTo(x1, y1 + hight);
        mc.lineTo(x1, y1);
        mc.endFill();
    }
    public static function ginkgoCircle(mc:MovieClip,
                                        nX:Number,
                                        nY:Number,
                                        nR:Number,
                                        nStD :Number,
                                        nInD :Number,
                                        line :Array,
                                        base :Array) : Void {
        if(line[1] == undefined){line[1] = 1;}
        if(line[0] == undefined){line[0] = 0x000000;}
        if (line[1] == 0) {
            mc.lineStyle();
        }else{
            mc.lineStyle(line[1],line[0]);
        }

        if(base == undefined || base == null){
        	mc.beginFill();
        }else{

        	if(base.length > 2){
	        	mc.beginGradientFill(base[0],base[1],base[2],base[3],base[4]);
        	}else{
        		mc.beginFill(Number(base[0]),Number(base[1]));
        	}

        }
        var segmentDegrees :Number = 45;

        if(nInD <= segmentDegrees){
            var pointlist :Array
                = __ginkgoCircleBitPoint(nX,nY,nR,nStD,nInD);
            mc.moveTo(pointlist[0], pointlist[1]);
            mc.lineTo(pointlist[2], pointlist[3]);
            mc.curveTo(pointlist[6], pointlist[7],
                       pointlist[4], pointlist[5]);
            mc.lineTo(pointlist[0], pointlist[1]);
        }else{
            var segme :Number = Math.floor(nInD / segmentDegrees);
            var amari :Number = nInD % segmentDegrees;
            if(amari != 0){
                var pointlist :Array
                    = __ginkgoCircleBitPoint(nX,nY,nR,nStD,amari);
                mc.moveTo(pointlist[0], pointlist[1]);
                mc.lineTo(pointlist[2], pointlist[3]);
                mc.curveTo(pointlist[6], pointlist[7],
                           pointlist[4], pointlist[5]);
            };
            var deg = amari;
            for(var i=0;i<segme;i++){
                var pointlist :Array = __ginkgoCircleBitPoint
                    (nX,nY,nR,
                     nStD + deg + i * segmentDegrees,
                     segmentDegrees);
                if(i == 0 && amari == 0){
                    mc.moveTo(pointlist[0], pointlist[1]);
                    mc.lineTo(pointlist[2], pointlist[3]);
                }
                mc.curveTo(pointlist[6], pointlist[7],
                           pointlist[4], pointlist[5]);
                if(i == segme - 1){
                    mc.lineTo(pointlist[0], pointlist[1]);
                }
            }
        }
        mc.endFill();
    }
    private static function __ginkgoCircleBitPoint(nX :Number,
                                                   nY :Number,
                                                   nR :Number,
                                                   nStD :Number,
                                                   nInD :Number) : Array {
        var raStD = nStD * Math.PI / 180;
        var raInD = nInD * Math.PI / 180;
        var nS1X :Number = nX + (nR * Math.cos(raStD));
        var nS1Y :Number = nY + (nR * Math.sin(raStD));
        var nSLX :Number = nX + (nR * Math.cos(raStD + raInD));
        var nSLY :Number = nY + (nR * Math.sin(raStD + raInD));
        var nCtlX :Number =  nSLX + nR * Math.tan(raInD/2) 
            * Math.cos(raStD + raInD - Math.PI/2);
        var nCtlY :Number =  nSLY + nR * Math.tan(raInD/2) 
            * Math.sin(raStD + raInD - Math.PI/2);
        return [nX,nY,nS1X,nS1Y,nSLX,nSLY,nCtlX,nCtlY];
    }
    public static function circle(target_mc:MovieClip,
                                  nX:Number,
                                  nY:Number,
                                  nR:Number,
                                  line:Array,
                                  base:Array):Void {
    }
    public static function octagonbox(mc:MovieClip,
                               x1:Number,
                               y1:Number,
                               width:Number,
                               hight:Number,
                               round:Number,
                               line:Array,
                               base:Array) : Void {
                               	
        if(line[1] == undefined){line[1] = 1;}
        if(line[0] == undefined){line[0] = 0x000000;}
        if (line[1] == 0) {
            mc.lineStyle();
        }else{
            mc.lineStyle(line[1],line[0]);
        }
        if(base == undefined || base == null){
        	mc.beginFill();
        }else{

        	if(base.length > 2){
	        	mc.beginGradientFill(base[0],base[1],base[2],base[3],base[4]);
        	}else{
        		mc.beginFill(Number(base[0]),Number(base[1]));
        	}

        }
        if(round == undefined || isNaN(round) == true){
        	round = 0;
        }
        if(0 > (width - round) || 0 > (hight - round) ){
        	round = 0;
        }

        if(width > 0){
		    mc.moveTo(x1 + round, y1);//1
	        mc.lineTo(x1 + width - round, y1);//2
	        mc.lineTo(x1 + width, y1 + round);//3
	        
	        mc.lineTo(x1 + width, y1 + hight - round);//4
	        mc.lineTo(x1 + width - round, y1 + hight);//5
	        
	        mc.lineTo(x1 + round, y1 + hight);//6
	        mc.lineTo(x1 , y1 + hight - round);//7
	        
	        mc.lineTo(x1 , y1 + round);//8
	        
	        mc.lineTo(x1 + round, y1);//9
	        mc.endFill();
        	
        }else{
	        mc.moveTo(x1, y1);
	        mc.lineTo(x1 + 1, y1);
	        mc.lineTo(x1 + 1, y1 + hight);
	        mc.lineTo(x1, y1 + hight);
	        mc.lineTo(x1, y1);
	        mc.endFill();
        }


    }
    public static function roundbox(mc:MovieClip,
                               x1:Number,
                               y1:Number,
                               width:Number,
                               hight:Number,
                               round:Array,
                               line:Array,
                               base:Array) : Void {
    
        if(line[1] == undefined){line[1] = 1;}
        if(line[0] == undefined){line[0] = 0x000000;}
        if (line[1] == 0) {
            mc.lineStyle();
        }else{
            mc.lineStyle(line[1],line[0]);
        }
        if(base == undefined || base == null){
        	mc.beginFill();
        }else{
        	if(base.length > 2){
	        	mc.beginGradientFill(base[0],base[1],base[2],base[3],base[4]);
        	}else{
        		mc.beginFill(Number(base[0]),Number(base[1]));
        	}
        }
        if(round == undefined || round.length < 0 ){
        	var round:Array = [0,0,0,0];
        }

        if(0 > (width - round[0]) || 0 > (hight - round[0]) ){
        	var round:Array = [0,0,0,0];
        }
		
        if(width  > 0){
        	if(width - (round[2]*2) < 0){
        		round[2] = width;
        	}

		    mc.moveTo(x1 + round[0], y1);//1

	        mc.lineTo(x1 + width - round[2], y1);//2
	        mc.curveTo(x1 + width , y1  ,x1 + width ,y1 + round[3]);
	        mc.lineTo(x1 + width, y1 + round[3] );//3
	        
	        mc.lineTo(x1 + width, y1 +  hight  - round[3] );//4
	        
	        mc.curveTo(x1 + width , y1 + hight, x1 + width - round[2] , y1 + hight);
	        mc.lineTo(x1 + width - round[2], y1 + hight);//5
	        
	        mc.lineTo(x1 + round[0], y1 + hight );//6
	        
	        mc.curveTo(x1, y1+ hight, x1,y1+hight- round[1]);
	        mc.lineTo(x1 , y1 + hight - round[1]); //7
	        
	        mc.lineTo(x1 , y1 + round[1]); //8
	        mc.curveTo(x1, y1, x1 + round[0],y1);
	        
	        mc.lineTo(x1 + round[0], y1);//9
	        mc.endFill();
        
        
        }else{
	        mc.moveTo(x1, y1);
	        mc.lineTo(x1 + 1, y1);
	        mc.lineTo(x1 + 1, y1 + hight);
	        mc.lineTo(x1, y1 + hight);
	        mc.lineTo(x1, y1);
	        mc.endFill();
        }
     }  
} 

新建一个Fla文件,画一个影片剪辑拖入场景三次,分别取名叫:mc,mc2,mc3,并新建一层,将下面的代码复制进去

import ToolTips;
var tooltips:ToolTips = new ToolTips(this,[mc,mc2,mc3]);
mc.tooltipText = "提示内容";
mc2.tooltipText = "提示内容2";
mc3.tooltipText = "提示内容3";
tooltips.setToolTips();
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
	tooltips.hitCheck();
};
Mouse.addListener(mouseListener);

注意:ToolTips.as 和 Shape.as 和 你的fla文件要放在同一目录。

声明:类文件是小日本所写,我只是整理了一下,并附上了使用方法。


效果如下:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
摘要 UltraWinChart与ASP.NET UltraWebChart 一样,提供了丰富的对象模块,可视化的显示大量以及各种分类信息,为Windows Forms应用程序带来前所未有的方便。UltraWinChart内置了大量的图形备选项,包含了设计时各种选项,以及内置的美学增强功能。使得图表数据具有前所未有的心动、精美和专业。 组件列表 技术特性 应用场景 适用于.NET环境下图表显示应用程序 运用优势 2D/3D图表类型 — ;;; ;;; ;;; ;;; 包含了所有主要的图表类型:Bar, Column, Line, Area, Pie, Scatter, Bubble, HeatMap, Candle, HiLow, and OpenClose Financial等等。 智能化显示功能 — ;;; ;;; ;;; ;;; UltraWinChart独有的IntelliRend™;;;技术,大大提高了使用效率和可用性。我们将每一种便利,直观的设计理念,高级开发人员控件都融入于UltraWinChart之。 数据绑定和非绑定模式 — ;;; ;;; ;;; ;;; 使用DataSource属性,可从数据库或数组读取图表。内部的过滤让可提供的数据模式于所需绘制的图表选择类型相匹配。更可让开发者在图表绘制调整行和列的包含/非包含的情况。 强大的美学增强— 图表不仅仅采用点阵表示,最重要的是数据的外观显示。为了轻松的显示您的图表,UltraWinChart提供了内置的增强功能: 1) 边缘圆滑过渡-边缘圆滑过渡的显示图表图像,生成高级数据显示,并自动圆滑边缘和颜色转换。 2)alpha混合和透明 — UltraWinChart提供了完整的alpha混合和透明控件,而且可以全球设置。 3)背景图象 —可以在图表的背景显示一些公司的数据信息,例如公司的logo标志和“机密”的水印记号。 4)增强的颜色模式 —可避免显示多余的点或杂乱的图表项。 5)创新的分层设计 — UltraWinChart提供了分层设计,并可自动混合这些分层,以达到最佳的视觉效果。 6)图标符号 —UltraWinChart可生成大量的图标集,完全控制图标的外观。 标签 - 高级工具使用提示帮助—可完全定制工具提示,提供了优雅的停靠并显示了对细节的注重。 设计时超级方便 —能够真正帮助开发者实现RAD(实时应用程序开发)。UltraWinChart 提供了高级的用户界面属性编辑器,所见即所得的图表设置,加上与所选图表相关联的上下文属性以及设计时绑定到一个DataSet。 支持Windows事件 —提供了丰富的无缝集成的事件集,监测用户与图表数据的交互。 数据高亮显示—当鼠标移动,移上或点击时,图表项的数据将会自动高亮显示,提供给应用程序的用户丰富强大的交互功能。 强调细节—UltraWinChart 加强了细节部分,其包括RAD设计时配置、自动数据缩放和数据高亮显示、高级工具使用提示帮助、完全可自定义的图标符号、标签、打印等等。 开发环境 ";;;Microsoft Visual Studio .NET Microsoft Visual Basic .NET";;; ";;;Microsoft Visual C++ .NET Microsoft Visual C# .NET";;; .NET Common Language Runtime V1.0 支持平台 标准报价 5,450 元人民币 * 以上报价仅供参考,具体以厂商正式报价为准。 电话 021-58549800 Email: tools@sh.grapecity.com http://www.grapecity.com/china
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值