0
\$\begingroup\$

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;
var miniatura:MovieClip = _scene.d1[link];
miniatura.addEventListener(MouseEvent.CLICK, 
                           function(e:Event):void {
                               MainSoundManager._sm.stopAllSounds();
                               GameManager.loadSection(link, false);
                           });          
miniatura.addEventListener(MouseEvent.MOUSE_OVER,
                           function(e:Event):void {
                               miniatura.filters = [myGlow];
                               miniatura.gotoAndStop(2);
                               _control.visible = true;
                               _controle.gotoAndPlay(2);
                           });
miniatura.addEventListener(MouseEvent.MOUSE_OUT,
                           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);
                           });
miniatura.addEventListener(MouseEvent.MOUSE_OUT, 
                             function(e:Event):void { 
                             glowMobilha.alpha = 0; 
                             miniatura.filters = [glowMobilha]; 
                             _controle.visible = false; 
                             _controle.gotoAndStop(1); 
                           });

is it the best solution?

\$\endgroup\$
1
  • \$\begingroup\$ Ah, thanks for the code. My answer is not relevant then. \$\endgroup\$
    – ashes999
    Commented May 1, 2012 at 15:20

2 Answers 2

1
\$\begingroup\$

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

miniatura.filters = [];

Put that in your MOUSE_OUT handler.

\$\endgroup\$
0
1
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .