我正在做一个有两个过滤器的按钮,当用户有光标在它上面的时候(鼠标过去),还有两个过滤器在光标退出的时候发出。相当基本的东西。
过滤器是Glow和DropShadow。辉光应用于文本,而DropShadow应用于按钮背景(一个简单的矩形)。
这里的问题是GlowIn的转换不起作用。当鼠标超过过滤器时,它会立即将过滤器应用到完全阿尔法。不过,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"});
}发布于 2013-09-27 16:53:09
问题是辉光滤波器的alpha属性范围是0到1,而不是0到100。但是Tweener仍然尊重你提供的值,所以在插值alpha值时,它会跳到1以上,在达到100的过程中,很可能是在第一个帧中。这就是为什么你看到它立刻变成全α的原因。如果你把你的100换成1,那就解决了。
相反的中间值仍然能像预期的那样工作,因为alpha值被限制在1,所以即使有人试图将它设置为50,60等,当辉光滤波器存储实际值时,它将其限制在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-27 14:41:32
编辑:以前的答案不正确,因为混淆的因素!请看到新的答案。
发布于 2013-09-27 14:59:11
专业提示:不要费心使用推特纳:)使用来自GreenSock的Tweenmax或来自Starling的杂耍者--它们只是最好的
https://stackoverflow.com/questions/19049806
复制相似问题