开发者

Flex: How to create a color Glow filter with duration

I need to highlight a button's border, so I have created a glow filter lik开发者_运维知识库e this:

<s:GlowFilter id="GlowFilter1"
  color="0xD9D919"
   blurX="30" blurY="40"
  alpha="1"
 />

The problem is that I don't know to remove the effect. The effect remains in the opction as it was highlighted. Thus, I'd like to set a duration, or something that removes the effect I create.

Thanks.


According to adobe live docs.

Removing filters from a display object

Removing all filters from a display object is as simple as assigning a null value to the filters property:

myDisplayObject.filters = null;

So if you want, you can set filter to the null after some time using Timer, or put this in the event (e.g. MouseOut)


IF you use Flex 3, use the AnimateProperty class.

There is an example in the doc


I can't say I'm a fan for Flex's filters/animations. They seems overly cluttered to me. I personally use TweenMax because it's fast and easy to use. In this case, if you wanted to create a glow filter, you'd do this:

import com.greensock.*; 
import com.greensock.easing.*;
import com.greensock.plugins.*;

// First you need to 'activate' the plugin.  Only need to do this once on app startup.
TweenPlugin.activate([GlowFilterPlugin]);

// Fade in glow
TweenMax.to(yourComponent, 1, {glowFilter:{color:0x91e600, alpha:1, blurX:30, blurY:30}});

// Fade out glow
TweenMax.to(yourComponent, 1, {glowFilter:{alpha:0, remove:true}});

Easy huh? :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜