制作类似工具提示的复活节彩蛋

时间:2014-03-02 20:03:00

标签: actionscript-3 tooltip

我正在尝试在我的AS3应用程序中制作一个复活节彩蛋,当用户将光标悬停在单独的触发器上时会出现,并在他们停止悬停在它上面时消失。

var hideEast:Tween=new Tween(easter_mc,"alpha",null,100,0,1,false);
easterTrigger_btn.addEventListener(MouseEvent.MOUSE_OVER, triEas);
easterTrigger_btn.addEventListener(MouseEvent.MOUSE_OUT, remEas);
function triEas (e:MouseEvent):void{
    var showEast:Tween=new Tween(easter_mc,"alpha",null,0,100,1,false);
}

function remEas (e:MouseEvent):void{
    var hideEast;
}

这是我尝试使用的代码。它会在触发器悬停时显示影片剪辑,但是当触发器不再悬停时,影片剪辑会保留。

1 个答案:

答案 0 :(得分:0)

因为您的MOUSE_OUT处理程序中没有任何动画。 另外,我建议杰克多伊尔补充引擎 - TweenLite

trigger.addEventListener(MouseEvent.MOUSE_OVER, onOver, false, 0, true);
trigger.addEventListener(MouseEvent.MOUSE_OUT, onOut, false, 0, true);

function onOver(e:MouseEvent):void {
    TweenLite.to(trigger, 0.3, {alpha: 1, ease: Sine.easeOut});
}

function onOut(e:MouseEvent):void {
    TweenLite.to(trigger, 0.5, {alpha: 0, ease: Sine.easeInOut});
}

或者你可以进一步使用可见性。

trigger.alpha = 0;
trigger.visible = false;

TweenPlugin.activate([AutoAlphaPlugin]);

trigger.addEventListener(MouseEvent.MOUSE_OVER, onOver, false, 0, true);
trigger.addEventListener(MouseEvent.MOUSE_OUT, onOut, false, 0, true);

function onOver(e:MouseEvent):void {
    TweenLite.to(trigger, 0.3, {autoAlpha: 1, ease: Sine.easeOut});
}

function onOut(e:MouseEvent):void {
    TweenLite.to(trigger, 0.5, {autoAlpha: 0, ease: Sine.easeInOut});
}