// Example: Glow Filter package { import flash.display.*; import flash.events.*; import flash.filters.*; public class Wk9GlowFilter extends MovieClip { // Create a new GlowFilter object with a color of red, // a wider blur, blurX == 5, than the height, blurY == 2, // and set knockout to true, so the center shows what's behind it var gf:GlowFilter = new GlowFilter(0xbe1313,100,5,2,4,2,false,true); // Boolean variable to keep track of when we're increasing // the height and width of the blur and when we're decreasing it var blurUp:Boolean = true; sun.filters = [gf]; function Wk9GlowFilter( ) { // Add the GlowFilter within an array to the sun MovieClip // Note: You could put many different kinds of filters // in an array and add them to an object // Add a frame event that will change the // blur height and width at each frame sun.addEventListener( Event.ENTER_FRAME, glowmore ); // Add a listener to set the knockout of the filter to false // when the mouse is over the sun, // so that the sun will instead show what's behind it sun.addEventListener( MouseEvent.MOUSE_OVER, knockoutFalse ); // Add a listener to set the knockout of the filter to true // when the mouse moves off the sun, // so that what's behind the sun will show sun.addEventListener( MouseEvent.MOUSE_OUT, knockoutTrue ); } // end constructor function glowmore(evt: Event) { // The width of the blur will vary betwee 5 and 50 if (gf.blurX == 5) { blurUp = true; } else if ( gf.blurX == 50 ) { blurUp = false; } // Increase or decrease the width of the blur more than the height if (blurUp == true) { gf.blurY += 0.1; gf.blurX += 0.5; } else { gf.blurY -= 0.1; gf.blurX -= 0.5; } // Add the changed filter to the sun Movieclip sun.filters = [gf]; } function knockoutFalse(evt: MouseEvent) { gf.knockout = false; sun.filters = [gf]; } function knockoutTrue(evt: MouseEvent) { gf.knockout = true; sun.filters = [gf]; } } }