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\$
  • \$\begingroup\$ Ah, thanks for the code. My answer is not relevant then. \$\endgroup\$ – ashes999 May 1 '12 at 15:20
1
\$\begingroup\$

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

miniatura.filters = [];

Put that in your MOUSE_OUT handler.

\$\endgroup\$
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\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.