1

我有这个 ActionScript 2.0 文件,用于为我的 flash 中的某些 MovieClips 创建工具提示。我用#include“tooltip.as”在我的场景的第一帧中调用tooltip.as 并且我给出了一个包含我的工具提示内容的字符串

var tooltip:String="Assembleia Geral\nAlice Freitas, Presidente\nJorge Correia, 1º Secretário\nCeleste Madureira, 2º Secretário\n"

工具提示.as:

import mx.transitions.Tween;
var lst:Object = new Object ();
this.createEmptyMovieClip ("d_mc", 650000);
var mc_isim:String = new String ();
function olustur (f_mc:MovieClip, f_str:String)
{
    var my_fmt:TextFormat = new TextFormat ();
    my_fmt.size = 13;
    my_fmt.font = "Arial";
    var w:Number = f_str.length * my_fmt.size / 3 * 2;
    var h:Number = 20;
    f_mc.createEmptyMovieClip ("tool_mc", 5);
    f_mc.tool_mc.createTextField ("tool_txt", 1, 5, 5, 10, 10);
    f_mc.tool_mc.tool_txt.autoSize = true;
    f_mc.tool_mc.tool_txt.setNewTextFormat (my_fmt);
    f_mc.tool_mc.tool_txt.text = f_str;
    f_mc.tool_mc.tool_txt._visible = false;
    f_mc.tool_mc.beginFill (0xCDCDCD, 80);
    f_mc.tool_mc.lineStyle (1);
    f_mc.tool_mc.moveTo (5, 5);
    f_mc.tool_mc.lineTo (f_mc.tool_mc.tool_txt._width+10, 5);
    f_mc.tool_mc.lineTo (f_mc.tool_mc.tool_txt._width+10, (f_mc.tool_mc.tool_txt._height + 5));
    f_mc.tool_mc.lineTo (5, (f_mc.tool_mc.tool_txt._height + 5));
    f_mc.tool_mc.lineTo (5, 5);
    f_mc.tool_mc.endFill ();
    f_mc.tool_mc._y = 0 - h;
    f_mc.tool_mc._visible = false;
    var bos:Tween = new Tween (f_mc.tool_mc, "_x", null, f_mc.tool_mc._x, f_mc.tool_mc._x, 2, true);
    bos.onMotionFinished = function ()
    {
        f_mc.tool_mc._visible = true;
        var my:Tween = new Tween (f_mc.tool_mc, "_alpha", null, 0, 100, 1, true);
        my.onMotionFinished = function ()
        {
            f_mc.tool_mc.tool_txt._visible = true;
            my.stop ();
        };
    };
}
lst.onMouseMove = function ()
{
    d_mc.startDrag (true);
    if (typeof (eval (d_mc._droptarget)) == "movieclip")
    {
        f_mc = eval (d_mc._droptarget);
        if (f_mc.tooltip != undefined)
        {
            d_mc._visible = true;
            if (mc_isim != f_mc._name)
            {
                olustur (d_mc, f_mc.tooltip);
                mc_isim = f_mc._name;
            }
        }
    }
    else
    {
        d_mc._visible = false;
    }
};
Mouse.addListener (lst);

我的问题是:我可以让这个工具提示出现得更快吗?大约需要 2 秒钟才会出现。

4

1 回答 1

1

TweenAS2构造函数的第 6 个参数控制补间的持续时间(请参阅AS2 补间参考)。当您的初始补间完成时会出现您的工具提示,并且该初始补间需要两秒钟:

var bos:Tween = new Tween (f_mc.tool_mc, "_x", null, f_mc.tool_mc._x, f_mc.tool_mc._x, 2, true);

您可以根据需要更改2为多少秒。例如,这将导致工具提示仅在0.5几秒钟后出现:

var bos:Tween = new Tween (f_mc.tool_mc, "_x", null, f_mc.tool_mc._x, f_mc.tool_mc._x, 0.5, true);
于 2013-03-21T21:16:56.807 回答