Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
    
Ah, thanks for the code. My answer is not relevant then. –  ashes999 May 1 '12 at 15:20

2 Answers 2

up vote 1 down vote accepted

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

miniatura.filters = [];

Put that in your MOUSE_OUT handler.

share|improve this answer
    
Thank you so much!! –  Dyego May 1 '12 at 16:40

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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