0

我正在做一个带有两个过滤器的按钮,当用户将光标悬停在它上面时(鼠标悬停)和两个过滤器补间,当光标退出它时。很基本的东西。

过滤器是 Glow 和 DropShadow。Glow 应用于文本,而 DropShadow 应用于按钮背景(一个简单的矩形)。

这里的问题是 GlowIn 的转换不起作用。当鼠标悬停在过滤器上时,它会立即以全 alpha 应用过滤器。GlowOut 虽然有效。

虽然它设置为 0.25 时间,但为了确定,我尝试了整整 5 秒,但它仍然没有工作,所以它不是时间问题。

这是我的代码:

import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
import flash.filters.GlowFilter;
FilterShortcuts.init();

texto.mouseEnabled = false;

this.addEventListener(MouseEvent.MOUSE_OVER, FiltersIn);
this.addEventListener(MouseEvent.MOUSE_OUT, FiltersOut);

var glow = new GlowFilter(0xFFFFFF, 0, 5, 5, 3, 250);
texto.filters = [glow];

function FiltersIn(MouseEvent):void{
    Tweener.addTween(this, {_DropShadow_distance:5, _DropShadow_alpha:1, _DropShadow_blurX:5, _DropShadow_blurY:5, time:0.25, transition:"easeOutCubic"});
    Tweener.addTween(texto, {_Glow_alpha:100, time:0.25, transition:"easeOutCubic"});
}
function FiltersOut(MouseEvent):void{
    Tweener.addTween(this, {_DropShadow_distance:0, _DropShadow_alpha:0, _DropShadow_blurX:0, _DropShadow_blurY:0, time:0.25, transition:"EaseInCubic"});
    Tweener.addTween(texto, {_Glow_alpha:0, time:0.25, transition:"easeInCubic"});
}
4

3 回答 3

1

问题是alpha辉光滤镜的属性范围是从 0 到 1,而不是 0 到 100。但是 Tweener 仍然尊重您提供的值 - 所以在插值 alpha 值时,它会跳到 1 之外, 100,可能在第一帧。所以这就是为什么你会立即看到它进入完整的 alpha 版本。如果您将 100 换成 1,那将解决它。

反向补间仍然按预期工作的原因是因为 alpha 值被限制为 1,所以即使尝试将其设置为 50、60 等到 100,当辉光过滤器存储实际值时,它也会限制它为 1,允许反向补间在 1 和 0 之间平滑插值。

这是适当的编辑:

import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
import flash.filters.GlowFilter;
FilterShortcuts.init();

texto.mouseEnabled = false;

this.addEventListener(MouseEvent.MOUSE_OVER, FiltersIn);
this.addEventListener(MouseEvent.MOUSE_OUT, FiltersOut);

var glow = new GlowFilter(0xFFFFFF, 0, 5, 5, 3, 250);
texto.filters = [glow];

function FiltersIn(MouseEvent):void{
    Tweener.addTween(this, {_DropShadow_distance:5, _DropShadow_alpha:1, _DropShadow_blurX:5, _DropShadow_blurY:5, time:0.25, transition:"easeOutCubic"});
    Tweener.addTween(texto, {_Glow_alpha:1, time:0.25, transition:"easeOutCubic"});
}
function FiltersOut(MouseEvent):void{
    Tweener.addTween(this, {_DropShadow_distance:0, _DropShadow_alpha:0, _DropShadow_blurX:0, _DropShadow_blurY:0, time:0.25, transition:"EaseInCubic"});
    Tweener.addTween(texto, {_Glow_alpha:0, time:0.25, transition:"easeInCubic"});
}
于 2013-09-27T16:53:09.827 回答
0

编辑:由于混杂因素,先前的答案不正确!请查看新答案。

于 2013-09-27T14:41:32.717 回答
-3

专业提示:不要费心使用 Tweener :) 使用 GreenSock 的 Tweenmax 或 Starling 的 Juggler - 它们是最好的

于 2013-09-27T14:59:11.317 回答