`
keren
  • 浏览: 1560356 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

flash Tooltip类

 
阅读更多
http://www.flepstudio.com/flash/actionscript3/documentation/html/com_flepstudio_text_ToolTip.html
package com.flepstudio.text
{
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
     
    /**
     * ToolTip is a ValueObject for the FlepStudio API.
     * This class produces a tooltip advice on mouse rollover
     *
     * @author Filippo Lughi
     * @version Actionscript 3.0
     */
    public class ToolTip extends MovieClip
    {
        private var _bg_color:uint;
        private var _text_color:uint;
        private var _text_size:int;
        private var _font:String;
        private var _tool_text:String;
        private var _field_txt:TextField;
        private var _alpha_color:Number;
         
        private var ratio:int=10;
        private var holder_mc:MovieClip;
        private var bg_mc:MovieClip;
        private var father:MovieClip;
         
        /**
         * Construct a new ToolTip instance
         *
         * @param        .bc        uint         -- background color
         * @param        .tc            uint         -- text color
         * @param        .ts            int            -- text size
         * @param        .f            String        -- the font to use
         * @param        .tt            String        -- text of the tooltip
         * @param        .n            Number     -- alpha of background color
         */
        public function ToolTip(bc:uint,tc:uint,ts:int,f:String,tt:String,n:Number)
        {
            bg_color=bc;
            text_color=tc;
            text_size=ts;
            font=f;
            tool_text=tt;
            alpha_color=n;
             
            addEventListener(Event.ADDED_TO_STAGE,init);
             
            mouseEnabled=false;
            alpha=0;
        }
         
        /**
         * Background color
         */
        public function get bg_color():uint
        {
            return _bg_color;
        }
         
        public function set bg_color(c:uint):void
        {
            _bg_color=c;
        }
         
        /**
         * Text color
         */
        public function get text_color():uint
        {
            return _text_color;
        }
         
        public function set text_color(c:uint):void
        {
            _text_color=c;
        }
         
        /**
         * Text size
         */
        public function get text_size():int
        {
            return _text_size;
        }
         
        public function set text_size(n:int):void
        {
            _text_size=n;
        }
         
        /**
         * The font
         */
        public function get font():String
        {
            return _font;
        }
         
        public function set font(s:String):void
        {
            _font=s;
        }
         
        /**
         * The text
         */
        public function get tool_text():String
        {
            return _tool_text;
        }
         
        public function set tool_text(s:String):void
        {
            _tool_text=s;
        }
         
        /**
         * The text
         */
        public function get field_txt():TextField
        {
            return _field_txt;
        }
         
        public function set field_txt(t:TextField):void
        {
            _field_txt=t;
        }
         
        /**
         * The alpha color
         */
        public function get alpha_color():Number
        {
            return _alpha_color;
        }
         
        public function set alpha_color(n:Number):void
        {
            _alpha_color=n;
        }
         
        /**
         * Init the class
         *
         * @param        .evt                Event
         */
        private function init(evt:Event):void
        {
            removeEventListener(Event.ADDED_TO_STAGE,init);
             
            father=parent as MovieClip;
             
            createHolder();
            createTextField();
            createBackground();
            fixPosition();
            fadeIn();
            addEventListener(Event.ENTER_FRAME,addMovement);
        }
         
        /**
         * Container MovieClip creation
         *
         */
        private function createHolder():void
        {
            holder_mc=new MovieClip();
            addChild(holder_mc);
        }
         
        /**
         * TextField tooltip creation
         *
         */
        private function createTextField():void
        {
            field_txt=new TextField();
            field_txt.multiline=true;
            field_txt.selectable=false;
            field_txt.embedFonts=true;
            field_txt.antiAliasType=AntiAliasType.ADVANCED;
            field_txt.autoSize=TextFieldAutoSize.LEFT;
            field_txt.defaultTextFormat=getFormat();
            field_txt.htmlText=tool_text+"  ";
            field_txt.width=field_txt.textWidth+10;
            field_txt.height=field_txt.textHeight+20;
            holder_mc.addChild(field_txt);
        }
         
        /**
         * Get a text format
         *
         * @return                                TextFormat                the textfield's format of tooltip
         */
        private function getFormat():TextFormat
        {
            var format:TextFormat=new TextFormat();
            format.font=font;
            format.size=text_size;
            format.color=text_color;
            return format;
        }
         
        /**
         * Background MovieClip creation
         *
         */
        private function createBackground():void
        {
            bg_mc=new MovieClip();
            bg_mc.graphics.beginFill(bg_color,alpha_color);
            bg_mc.graphics.drawRoundRect(-ratio,-ratio,field_txt.width+ratio*2,field_txt.height+ratio*2,ratio,ratio);
            holder_mc.addChild(bg_mc);
             
            holder_mc.swapChildren(field_txt,bg_mc);
        }
         
        /**
         * Position the tooltip
         *
         */
        private function fixPosition():void
        {
            if(father.mouseX  <  stage.stageWidth/2)
                x=father.mouseX;
            else
                x=father.mouseX-width;
            if(father.mouseY  <  stage.stageHeight/2)
                y=father.mouseY+height-ratio*2;
            else
                y=father.mouseY-height;
        }
         
        /**
         * Init fade-in section of tooltip
         *
         */
        private function fadeIn():void
        {
            bg_mc.addEventListener(Event.ENTER_FRAME,fadeInToolTip);
        }
         
        /**
         * Fade-in of tooltip
         *
         * @param        .evt                Event
         */
        private function fadeInToolTip(evt:Event):void
        {
            var distance:Number=1-alpha;
            var inertial:Number=distance*.2;
            alpha+=inertial;
            if(Math.abs(distance)  <= .1)
            {
                alpha=1;
                bg_mc.removeEventListener(Event.ENTER_FRAME,fadeInToolTip);
            }
        }
         
        /**
         * Movement of tooltip
         *
         * @param        .evt                Event
         */
        private function addMovement(evt:Event):void
        {
            if(father.mouseX  <  stage.stageWidth/2)
                x=father.mouseX;
            else
                x=father.mouseX-width+ratio*2;
            if(father.mouseY  <  stage.stageHeight/2)
                y=father.mouseY+height-ratio*2;
            else
                y=father.mouseY-height;
                 
            if(x  >  stage.stageWidth-width)
                x=stage.stageWidth-width;
            if(x  <  ratio*2)
                x=ratio*2;
        }
         
        /**
         * Remove this instance
         *
         */
        public function destroy():void
        {
            removeEventListener(Event.ENTER_FRAME,addMovement);
            bg_mc.removeEventListener(Event.ENTER_FRAME,fadeInToolTip);
            father.removeChild(this);
        }
    }
}
分享到:
评论

相关推荐

    flash 的几个tooltip显示

    flash 的几个tooltip显示 大概 7 8 个 效果可以下来看

    Flash Tooltip AS3 气泡提示框的源代码

     Flash Tooltip AS3 气泡提示框的源代码,内含有5个不同风格的Flash气泡提示框,大小不同、颜色不同,动态的效果也不同,作Flash产品展示的话,会用到Tips,本源代码用Flash CS3及以上版本可打开。

    [AS3]提示信息类-ToolTip(flash)

    [AS3]提示信息类-ToolTip(flash)

    as3 tooltip的例子

    一个tooltip例子。里面包含一个tooltip类,表示一个长方形的小弹出窗口,该窗口在用户将指针悬停在一个控件上时显示有关该控件用途的简短说明

    Flash 自定义 ToolTip

    As的自定义的ToolTip,可直接使用。对于新手学习了解AsToolTip原理比较好的一个实例

    CSS3提示框Tooltip动画.zip

    CSS3提示框Tooltip动画是一款利用CSS3实现的提示框Tooltip动画。当鼠标移到图标按钮上时,就会在按钮正上方弹出一个Tooltip提示框,并且伴有淡入淡出的效果。

    FLASH日历原文件。AS3.0版本

    FLASH日历原文件。AS3.0版本 DateChooser.as DateShape.as SuperCalendar.as ToolTip.as

    flash相册系统

    - multiple properties for the tooltip - optionally you can go to an URL on clicking an image instead of enlarging it You can install our component on several platforms, from simple ...

    open-flash-chart-2-ichor.zip

    what happens to the tooltip when two points are in the same position? you can re-size the charts missing data save the chart as an image You can highlight or emphasize one (or many) points PC ...

    有弹性的Flash悬停气泡提示特效的源文件

    内容索引:Flash源码,其它应用,flash气泡提示 一个有弹性的Flash悬停提示特效的Fla源文件,当你把鼠标放在按钮上的时候,立即会弹出一个提示框,还有缓冲效果,在允许的范围内,Tooltip会跟随鼠标移动。再此提示,...

    JQuery&CSS;&CSS;+DIV实例大全.rar

    支持3级的jquery天蓝色动画菜单下载,适合艺术类、儿童类网站使用 5)对话框 1.jquery仿div透明模态弹出窗插件下载 2.jquery实现多风格消息弹出框插件jGrowl下载 3.jQuery弹出层插件PopupDiv-v1.0下载(支持ajax...

    基本的前台 css,font 和 js 文件

    css: bootstrap.min.css... drop-down.js, echarts.min.js, example.js, jquery.dataTables.min.js, jquery-3.3.1.min.js, jszip.min.js, pdfmake.min.js, popper.min.js, style.js, tooltip.js, vfs_fonts.js , vue.js

    Web-CFJ ---&gt; 基本的前台 css,font 和 js 文件

    dataTables.buttons.min.js, dataTables.min.js, drop-down.js, echarts.min.js, example.js, jquery.dataTables.min.js, jquery-3.3.1.min.js, jszip.min.js, pdfmake.min.js, popper.min.js, style.js, tooltip.js...

    PrimeUI Widgets

    其中包括HtmlEditor、ImageCropper、Dialog、AutoComplete、 Flash based Chart等。并支持通过Ajax更新页面。 Optimus模块:提供简化JSF开发的解决方案。Optimus提供基于Google Guice IOC容器的注释来代替XML配置。...

    Highcharts-Gantt-8.1.2.zip

    tooltip数据提示框 当鼠标划过图形时,Highstock 可以将数据点或数据列的信息展示在提示框中,并且提示框会跟随用户的鼠标;我们做了大量工作,可以智能的显示离鼠标最近的点或被遮盖点的信息。 datetime时间轴 ...

    Highcharts-Stock-8.1.2.zip

    tooltip数据提示框 当鼠标划过图形时,Highstock 可以将数据点或数据列的信息展示在提示框中,并且提示框会跟随用户的鼠标;我们做了大量工作,可以智能的显示离鼠标最近的点或被遮盖点的信息。 datetime时间轴 ...

    Dundas.Chart.for.Winform.Enterprise.v7.1.0.1812.for.VS2008

    Custom label enhancements - New to Version 5.0, developers can associate a custom label to an image, a tooltip, an HREF or even an object Improved Data Labeling - Developers now have the opportunity ...

    vc实例精通源码,windows基本控件的使用Demo

    07_ToolTipDemo 使用ToolTip显示即时提示。 第4章(\ Chapter04) 示例描述:本章介绍窗体的使用方法和使用技巧。 01_WindowDemo 演示创建和显示窗体的方法。 02_TopMostWnd 让窗体保持在桌面最顶层。 03_...

Global site tag (gtag.js) - Google Analytics