Filtro de iluminado degradado

Flash Player 9 y posterior, Adobe AIR 1.0 y posterior

La clase GradientGlowFilter permite aplicar un efecto de iluminación mejorada a los objetos de visualización o a los objetos BitmapData. Este efecto proporciona un mayor control sobre el color de la iluminación y, de este modo, permite lograr un efecto de brillo más realista. Además, mediante el filtro de iluminado degradado, es posible aplicar un brillo degradado al borde interior, exterior o superior de un objeto.

En el siguiente ejemplo se dibuja un círculo en el escenario y se le aplica un filtro de iluminado degradado. A medida que se mueve el ratón hacia la derecha y abajo, la cantidad de desenfoque aumenta en dirección horizontal y vertical respectivamente. Además, cuando se hace clic en el escenario, la fuerza del desenfoque aumenta.

import flash.events.MouseEvent; 
import flash.filters.BitmapFilterQuality; 
import flash.filters.BitmapFilterType; 
import flash.filters.GradientGlowFilter; 
 
// Create a new Shape instance. 
var shape:Shape = new Shape(); 
 
// Draw the shape. 
shape.graphics.beginFill(0xFF0000, 100); 
shape.graphics.moveTo(0, 0); 
shape.graphics.lineTo(100, 0); 
shape.graphics.lineTo(100, 100); 
shape.graphics.lineTo(0, 100); 
shape.graphics.lineTo(0, 0); 
shape.graphics.endFill(); 
 
// Position the shape on the Stage. 
addChild(shape); 
shape.x = 100; 
shape.y = 100; 
 
// Define a gradient glow. 
var gradientGlow:GradientGlowFilter = new GradientGlowFilter(); 
gradientGlow.distance = 0; 
gradientGlow.angle = 45; 
gradientGlow.colors = [0x000000, 0xFF0000]; 
gradientGlow.alphas = [0, 1]; 
gradientGlow.ratios = [0, 255]; 
gradientGlow.blurX = 10; 
gradientGlow.blurY = 10; 
gradientGlow.strength = 2; 
gradientGlow.quality = BitmapFilterQuality.HIGH; 
gradientGlow.type = BitmapFilterType.OUTER; 
 
// Define functions to listen for two events. 
function onClick(event:MouseEvent):void 
{ 
    gradientGlow.strength++; 
    shape.filters = [gradientGlow]; 
} 
 
function onMouseMove(event:MouseEvent):void 
{ 
    gradientGlow.blurX = (stage.mouseX / stage.stageWidth) * 255; 
    gradientGlow.blurY = (stage.mouseY / stage.stageHeight) * 255; 
    shape.filters = [gradientGlow]; 
} 
stage.addEventListener(MouseEvent.CLICK, onClick); 
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);