我有这个ActionScript 2.0文件,用于为我的flash中的一些MovieClip创建工具提示。 我用 #include“tooltip.as”在我的场景的第一帧中调用tooltip.as 我正在给出一个包含我的工具提示内容的字符串
var tooltip:String="Assembleia Geral\nAlice Freitas, Presidente\nJorge Correia, 1º Secretário\nCeleste Madureira, 2º Secretário\n"
tooltip.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秒钟。
答案 0 :(得分:1)
AS2 Tween
构造函数的第6个参数控制补间的持续时间(请参阅AS2 Tween reference)。当您的初始补间完成时,您的工具提示会出现,并且初始补间需要两秒钟:
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);