Packageflash.filters
Classpublic class GlowFilter
InheritanceGlowFilter Inheritance BitmapFilter Inheritance Object

Player version: Flash Player 8

The GlowFilter class lets you apply a glow effect to various objects in Flash. You have several options for the style of the glow, including inner or outer glow and knockout mode. The glow filter is similar to the drop shadow filter with the distance and angle properties of the drop shadow set to 0.

The use of filters depends on the object to which you apply the filter:

You can also apply filter effects to images and video during authoring. For more information, see your authoring documentation.

If you apply a filter to a movie clip or button, the cacheAsBitmap property of the movie clip or button is set to true. If you clear all filters, the original value of cacheAsBitmap is restored.

This filter supports Stage scaling. However, it does not support general scaling, rotation, and skewing; if the object itself is scaled (if _xscale and _yscale are not 100%), the filter effect is not scaled. It is scaled only when the Stage is zoomed.

A filter is not applied if the resulting image exceeds 2880 pixels in width or height. For example, if you zoom in on a large movie clip with a filter applied, the filter is turned off if the resulting image exceeds the limit of 2880 pixels.

See also

flash.display.BitmapData.applyFilter()
Button.cacheAsBitmap
Button.filters
DropShadowFilter
MovieClip.cacheAsBitmap
MovieClip.filters
TextField.filters


Public Properties
 Property
  alpha : Number
The alpha transparency value for the color.
  blurX : Number
The amount of horizontal blur.
  blurY : Number
The amount of vertical blur.
  color : Number
The color of the glow.
  inner : Boolean
Specifies whether the glow is an inner glow.
  knockout : Boolean
Specifies whether the object has a knockout effect.
  quality : Number
The number of times to apply the filter.
  strength : Number
The strength of the imprint or spread.
 Properties inherited from class Object
 __proto__, __resolve, constructor, prototype
Public Methods
 Method
  
GlowFilter([color:Number], [alpha:Number], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [inner:Boolean], [knockout:Boolean])
Initializes a new GlowFilter instance with the specified parameters.
  
Returns a copy of this filter object.
 Methods inherited from class BitmapFilter
 clone
 Methods inherited from class Object
 addProperty, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toString, unwatch, valueOf, watch
Property detail
alphaproperty
public var alpha:Number

Player version: Flash Player 8

The alpha transparency value for the color. Valid values are 0 to 1. For example, 0.25 sets a transparency value of 25%. The default value is 1.


Example
The following example changes the alpha property on an existing movie clip when a user clicks it.
import flash.filters.GlowFilter;

var mc:MovieClip = createGlowFilterRectangle("GlowFilterAlpha");
mc.onRelease = function() {
    var filter:GlowFilter = this.filters[0];
    filter.alpha = 0.4;
    this.filters = new Array(filter);
}

function createGlowFilterRectangle(name:String):MovieClip {
    var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());
    var w:Number = 100;
    var h:Number = 100;
    rect.beginFill(0x003366);
    rect.lineTo(w, 0);
    rect.lineTo(w, h);
    rect.lineTo(0, h);
    rect.lineTo(0, 0);
    rect._x = 20;
    rect._y = 20;

    var filter:GlowFilter = new GlowFilter(0x000000, 0.8, 16, 16, 1, 3, false, false);
    var filterArray:Array = new Array();
    filterArray.push(filter);
    rect.filters = filterArray;
    return rect;
}

blurXproperty 
public var blurX:Number

Player version: Flash Player 8

The amount of horizontal blur. Valid values are 0 to 255 (floating point). The default value is 6. Values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized to render more quickly than other values.


Example
The following example changes the blurX property on an existing movie clip when a user clicks it.
import flash.filters.GlowFilter;

var mc:MovieClip = createGlowFilterRectangle("GlowFilterBlurX");
mc.onRelease = function() {
    var filter:GlowFilter = this.filters[0];
    filter.blurX = 20;
    this.filters = new Array(filter);
}

function createGlowFilterRectangle(name:String):MovieClip {
    var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());
    var w:Number = 100;
    var h:Number = 100;
    rect.beginFill(0x003366);
    rect.lineTo(w, 0);
    rect.lineTo(w, h);
    rect.lineTo(0, h);
    rect.lineTo(0, 0);
    rect._x = 20;
    rect._y = 20;

    var filter:GlowFilter = new GlowFilter(0x000000, 0.8, 16, 16, 1, 3, false, false);
    var filterArray:Array = new Array();
    filterArray.push(filter);
    rect.filters = filterArray;
    return rect;
}

blurYproperty 
public var blurY:Number

Player version: Flash Player 8

The amount of vertical blur. Valid values are 0 to 255 (floating point). The default value is 6. Values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized to render more quickly than other values.


Example
The following example changes the blurY property on an existing movie clip when a user clicks it.
import flash.filters.GlowFilter;

var mc:MovieClip = createGlowFilterRectangle("GlowFilterBlurY");
mc.onRelease = function() {
    var filter:GlowFilter = this.filters[0];
    filter.blurY = 20;
    this.filters = new Array(filter);
}

function createGlowFilterRectangle(name:String):MovieClip {
    var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());
    var w:Number = 100;
    var h:Number = 100;
    rect.beginFill(0x003366);
    rect.lineTo(w, 0);
    rect.lineTo(w, h);
    rect.lineTo(0, h);
    rect.lineTo(0, 0);
    rect._x = 20;
    rect._y = 20;

    var filter:GlowFilter = new GlowFilter(0x000000, 0.8, 16, 16, 1, 3, false, false);
    var filterArray:Array = new Array();
    filterArray.push(filter);
    rect.filters = filterArray;
    return rect;
}

colorproperty 
public var color:Number

Player version: Flash Player 8

The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000.


Example
The following example changes the color property on an existing movie clip when a user clicks it.
import flash.filters.GlowFilter;

var mc:MovieClip = createGlowFilterRectangle("GlowFilterColor");
mc.onRelease = function() {
    var filter:GlowFilter = this.filters[0];
    filter.color = 0x00FF33;
    this.filters = new Array(filter);
}

function createGlowFilterRectangle(name:String):MovieClip {
    var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());
    var w:Number = 100;
    var h:Number = 100;
    rect.beginFill(0x003366);
    rect.lineTo(w, 0);
    rect.lineTo(w, h);
    rect.lineTo(0, h);
    rect.lineTo(0, 0);
    rect._x = 20;
    rect._y = 20;

    var filter:GlowFilter = new GlowFilter(0x000000, .8, 16, 16, 1, 3, false, false);
    var filterArray:Array = new Array();
    filterArray.push(filter);
    rect.filters = filterArray;
    return rect;
}

innerproperty 
public var inner:Boolean

Player version: Flash Player 8

Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object).


Example
The following example changes the inner property on an existing movie clip when a user clicks it.
import flash.filters.GlowFilter;

var mc:MovieClip = createGlowFilterRectangle("GlowFilterInner");
mc.onRelease = function() {
    var filter:GlowFilter = this.filters[0];
    filter.inner = true;
    this.filters = new Array(filter);
}

function createGlowFilterRectangle(name:String):MovieClip {
    var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());
    var w:Number = 100;
    var h:Number = 100;
    rect.beginFill(0x003366);
    rect.lineTo(w, 0);
    rect.lineTo(w, h);
    rect.lineTo(0, h);
    rect.lineTo(0, 0);
    rect._x = 20;
    rect._y = 20;

    var filter:GlowFilter = new GlowFilter(0x000000, 0.8, 16, 16, 1, 3, false, false);
    var filterArray:Array = new Array();
    filterArray.push(filter);
    rect.filters = filterArray;
    return rect;
}

knockoutproperty 
public var knockout:Boolean

Player version: Flash Player 8

Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default is false (no knockout effect).


Example
The following example changes the knockout property on an existing movie clip when a user clicks it.
import flash.filters.GlowFilter;

var mc:MovieClip = createGlowFilterRectangle("GlowFilterKnockout");
mc.onRelease = function() {
    var filter:GlowFilter = this.filters[0];
    filter.knockout = true;
    this.filters = new Array(filter);
}

function createGlowFilterRectangle(name:String):MovieClip {
    var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());
    var w:Number = 100;
    var h:Number = 100;
    rect.beginFill(0x003366);
    rect.lineTo(w, 0);
    rect.lineTo(w, h);
    rect.lineTo(0, h);
    rect.lineTo(0, 0);
    rect._x = 20;
    rect._y = 20;

    var filter:GlowFilter = new GlowFilter(0x000000, 0.8, 16, 16, 1, 3, false, false);
    var filterArray:Array = new Array();
    filterArray.push(filter);
    rect.filters = filterArray;
    return rect;
}

qualityproperty 
public var quality:Number

Player version: Flash Player 8

The number of times to apply the filter. Valid values are 0 to 15. The default value is 1, which is equivalent to low quality. A value of 2 is medium quality, and a value of 3 is high quality. Filters with lower values are rendered more quickly.

For most applications, a quality value of 1, 2, or 3 is sufficient. Although you can use additional numeric values up to 15 to achieve different effects, higher values are rendered more slowly. Instead of increasing the value of quality, you can often get a similar effect, and with faster rendering, by simply increasing the values of blurX and blurY.


Example
The following example changes the quality property on an existing movie clip when a user clicks it.
import flash.filters.GlowFilter;

var mc:MovieClip = createGlowFilterRectangle("GlowFilterQuality");
mc.onRelease = function() {
    var filter:GlowFilter = this.filters[0];
    filter.quality = 1;
    this.filters = new Array(filter);
}

function createGlowFilterRectangle(name:String):MovieClip {
    var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());
    var w:Number = 100;
    var h:Number = 100;
    rect.beginFill(0x003366);
    rect.lineTo(w, 0);
    rect.lineTo(w, h);
    rect.lineTo(0, h);
    rect.lineTo(0, 0);
    rect._x = 20;
    rect._y = 20;

    var filter:GlowFilter = new GlowFilter(0x000000, 0.8, 16, 16, 1, 3, false, false);
    var filterArray:Array = new Array();
    filterArray.push(filter);
    rect.filters = filterArray;
    return rect;
}

strengthproperty 
public var strength:Number

Player version: Flash Player 8

The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. The default is 2.


Example
The following example changes the strength property on an existing movie clip when a user clicks it.
import flash.filters.GlowFilter;

var mc:MovieClip = createGlowFilterRectangle("GlowFilterStrength");
mc.onRelease = function() {
    var filter:GlowFilter = this.filters[0];
    filter.strength = 0.8;
    this.filters = new Array(filter);
}

function createGlowFilterRectangle(name:String):MovieClip {
    var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());
    var w:Number = 100;
    var h:Number = 100;
    rect.beginFill(0x003366);
    rect.lineTo(w, 0);
    rect.lineTo(w, h);
    rect.lineTo(0, h);
    rect.lineTo(0, 0);
    rect._x = 20;
    rect._y = 20;

    var filter:GlowFilter = new GlowFilter(0x000000, 0.8, 16, 16, 1, 3, false, false);
    var filterArray:Array = new Array();
    filterArray.push(filter);
    rect.filters = filterArray;
    return rect;
}

Constructor detail
GlowFilter()constructor
public function GlowFilter([color:Number], [alpha:Number], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [inner:Boolean], [knockout:Boolean])

Player version: Flash Player 8

Initializes a new GlowFilter instance with the specified parameters.

Parameters
color:Number [optional] — The color of the glow, in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000.
 
alpha:Number [optional] — The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1.
 
blurX:Number [optional] — The amount of horizontal blur. Valid values are 0 to 255 (floating point). The default value is 6. Values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized to render more quickly than other values.
 
blurY:Number [optional] — The amount of vertical blur. Valid values are 0 to 255 (floating point). The default value is 6. Values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized to render more quickly than other values.
 
strength:Number [optional] — The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. The default is 2.
 
quality:Number [optional] — The number of times to apply the filter. Valid values are 0 to 15. The default value is 1, which is equivalent to low quality. A value of 2 is medium quality, and a value of 3 is high quality.
 
inner:Boolean [optional] — Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object).
 
knockout:Boolean [optional] — Specifies whether the object has a knockout effect. The value true makes the object's fill transparent and reveals the background color of the document. The default is false (no knockout effect).

Example
The following example instantiates a new GlowFilter instance and applies it to a flat, rectangular shape.
import flash.filters.GlowFilter;

var rect:MovieClip = createRectangle(100, 100, 0x003366, "gradientGlowFilterExample");

var color:Number = 0x33CCFF;
var alpha:Number = 0.8;
var blurX:Number = 35;
var blurY:Number = 35;
var strength:Number = 2;
var quality:Number = 3;
var inner:Boolean = false;
var knockout:Boolean = false;

var filter:GlowFilter = new GlowFilter(color, 
                                        alpha, 
                                        blurX, 
                                        blurY, 
                                        strength, 
                                        quality, 
                                        inner, 
                                        knockout);
var filterArray:Array = new Array();
filterArray.push(filter);
rect.filters = filterArray;

function createRectangle(w:Number, h:Number, bgColor:Number, name:String):MovieClip {
    var mc:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());
    mc.beginFill(bgColor);
    mc.lineTo(w, 0);
    mc.lineTo(w, h);
    mc.lineTo(0, h);
    mc.lineTo(0, 0);
    mc._x = 20;
    mc._y = 20;
    return mc;
}

Method detail
clone()method
public function clone():GlowFilter

Player version: Flash Player 8

Returns a copy of this filter object.

Returns
GlowFilter — A new GlowFilter instance with all of the properties of the original GlowFilter instance.

Example
The following example creates three GlowFilter objects and compares them: filter_1 is created by using the GlowFilter constructor; filter_2 is created by setting it equal to filter_1; and clonedFilter is created by cloning filter_1. Notice that although filter_2 evaluates as being equal to filter_1, clonedFilter, even though it contains the same values as filter_1, does not.
import flash.filters.GlowFilter;

var filter_1:GlowFilter = new GlowFilter(0x33CCFF, 0.8, 35, 35, 2, 3, false, false);
var filter_2:GlowFilter = filter_1;
var clonedFilter:GlowFilter = filter_1.clone();

trace(filter_1 == filter_2);        // true
trace(filter_1 == clonedFilter);    // false

for(var i in filter_1) {
    trace(">> " + i + ": " + filter_1[i]);
    // >> clone: [type Function]
    // >> strength: 2
    // >> blurY: 35
    // >> blurX: 35
    // >> knockout: false
    // >> inner: false
    // >> quality: 3
    // >> alpha: 0.8
    // >> color: 3394815
}

for(var i in clonedFilter) {
    trace(">> " + i + ": " + clonedFilter[i]);
    // >> clone: [type Function]
    // >> strength: 2
    // >> blurY: 35
    // >> blurX: 35
    // >> knockout: false
    // >> inner: false
    // >> quality: 3
    // >> alpha: 0.8
    // >> color: 3394815
}
To further demonstrate the relationships between filter_1, filter_2, and clonedFilter, the following example modifies the knockout property of filter_1. Modifying knockout demonstrates that the clone() method creates a new instance based on the values of filter_1 instead of pointing to them in reference.
import flash.filters.GlowFilter;

var filter_1:GlowFilter = new GlowFilter(0x33CCFF, 0.8, 35, 35, 2, 3, false, false);
var filter_2:GlowFilter = filter_1;
var clonedFilter:GlowFilter = filter_1.clone();

trace(filter_1.knockout);            // false
trace(filter_2.knockout);            // false
trace(clonedFilter.knockout);        // false

filter_1.knockout = true;

trace(filter_1.knockout);            // true
trace(filter_2.knockout);            // true
trace(clonedFilter.knockout);        // false