我正在尝试使用rollOver创建一些具有发光效果的MovieClip,并且在rollOut上消除发光效果。但是当rollOut完成时,我应用过滤器的背景动画片段(一个简单的20 x 20矢量圈)突然出现锯齿状,当在rollOver / rollOut之前它看起来应该是平滑的。可能会发生什么?
我对AS3很新,因此这个例子还没有正常工作。例如:
*当你翻转项目时,它第一次立即显示发光的结束阶段而不是动画。我以为我会在构造函数中使用Tween.rewind()来避免这种情况,但这并不能解决问题。
*我也不确定TweenEvent.MOTION_CHANGE的addEventListener是否放在正确的位置。我尝试将它放在构造函数中,但这导致事件被_onMotionChange连续接收。
非常感谢对这些问题的一些帮助。但最重要的部分是发光滤光片消失后的锯齿状圆圈。
这是我到目前为止(缩写示例):
package
{
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.filters.GlowFilter;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
public class ScoreListItem extends MovieClip
{
private var _glowFilter:GlowFilter;
private var _tweenGlowFilterBlurX:Tween;
private var _tweenGlowFilterBlurY:Tween;
public function ScoreListItem():void
{
_glowFilter = new GlowFilter( 0xffffff, 1, 3, 3, 2, 1, false, false );
_tweenGlowFilterBlurX = new Tween( _glowFilter, 'blurX', Strong.easeIn, 1, 5, .8, true );
_tweenGlowFilterBlurY = new Tween( _glowFilter, 'blurY', Strong.easeIn, 1, 5, .8, true );
_tweenGlowFilterBlurX.rewind();
_tweenGlowFilterBlurY.rewind();
addEventListener( MouseEvent.ROLL_OVER, _onRollOver );
addEventListener( MouseEvent.ROLL_OUT, _onRollOut );
}
private function _onRollOver( event:Event )
{
trace( 'rollOver' );
_tweenGlowFilterBlurY.addEventListener( TweenEvent.MOTION_CHANGE, _onMotionChange );
_tweenGlowFilterBlurX.continueTo( 5, 1 );
_tweenGlowFilterBlurY.continueTo( 5, 1 );
}
private function _onRollOut( event:Event )
{
trace( 'rollOut' );
_tweenGlowFilterBlurY.addEventListener( TweenEvent.MOTION_CHANGE, _onMotionChange );
_tweenGlowFilterBlurX.continueTo( 1, 1 );
_tweenGlowFilterBlurY.continueTo( 1, 1 );
}
private function _onMotionChange( event:Event )
{
trace( 'motionChange' );
this.backgroundCircle.filters = [ _glowFilter ];
}
}
}
答案 0 :(得分:0)
我能够通过为TweenEvent.MOTION_FINISH添加一个eventlistener来简单地通过在_onRollOut中完成后删除过滤器来解决我的问题。这样,矢量圆形状的锯齿状边缘消失了,并且再次显示正常。
private function _onRollOut( event:MouseEvent )
{
_tweenGlowFilterBlurY.addEventListener( TweenEvent.MOTION_FINISH, _onRollOutFinish );
/* etc... */
}
private function _onRollOutFinish( event:TweenEvent )
{
this.label.filters = [];
}