# How to set blur on mouse over and remove on mouse out in AS3?

How can I do it? I want to active glow when the mouse is over a Sprite and remove it when the mouse is out. Is it possible?

I have the following code:

var myGlow:GlowFilter = new GlowFilter();
myGlow.color = 0xFFFFFF;
myGlow.blurX = glowMobilha.blurY = 20;
function(e:Event):void {
MainSoundManager._sm.stopAllSounds();
});
function(e:Event):void {
miniatura.filters = [myGlow];
miniatura.gotoAndStop(2);
_control.visible = true;
_controle.gotoAndPlay(2);
});
function(e:Event):void {
miniatura.gotoAndStop(1);
_control.visible = false;
_control.gotoAndStop(1);
});
miniatura.buttonMode = true;


I set the blur at:

miniatura.addEventListener(MouseEvent.MOUSE_OVER,
function(e:Event):void {
miniatura.filters = [myGlow];
miniatura.gotoAndStop(2);
_control.visible = true;
_controle.gotoAndPlay(2);
});


How can I "hide" the blur at:

miniatura.addEventListener(MouseEvent.MOUSE_OUT,
function(e:Event):void {
miniatura.gotoAndStop(1);
_control.visible = false;
_control.gotoAndStop(1);
});


UPDATE I think I found the solution in the following code:

miniatura.addEventListener(MouseEvent.MOUSE_OVER,
function(e:Event):void {
glowMobilha.alpha = 1;
miniatura.filters = [glowMobilha];
_controle.visible = true;
_controle.gotoAndPlay(2);
});
function(e:Event):void {
glowMobilha.alpha = 0;
miniatura.filters = [glowMobilha];
_controle.visible = false;
_controle.gotoAndStop(1);
});


is it the best solution?

• Ah, thanks for the code. My answer is not relevant then. – ashes999 May 1 '12 at 15:20

To remove the filter you need to assign to the .filters property:

miniatura.filters = [];


Put that in your MOUSE_OUT handler.

Sure it's possible. Just convert it into a button. For your four states:

• Up will be just your sprite (as usual)
• Over will be the sprite, with a glow sprite underneath

That should be it. FYI, you can put MovieClips inside; so your "glow" doesn't have to be a sprite, but it can be a pulsating glow MovieClip that contains some sort of animation.

Just make sure the last state on the button (the one that determines the "mouse over" area) is accurate and covers the area for all four states; that is, it shouldn't include the glow area, but just the core sprite area.