The GlowFilter Class


The GlowFilter Class

The GlowFilter class is designed to create glow effects on objects at runtime, both inner and outer.

It is important when using this class to import it first at the beginning of your script, like this:

 import flash.filters.GlowFilter; 

To instantiate a new instance of the GlowFilter class, use this code as a template:

[View full width]

var myFilter:GlowFilter = new GlowFilter(color, alpha, blurX, blurY, strength, quality, inner, knockout);

  • color The color of the glow in RGB. Default value of 0xFF0000.

  • alpha The alpha of the glow from 01. Default value of 1.0.

  • blurX The total amount of horizontal blur from 0255. Default value of 4.0.

  • blurY The total amount of vertical blur from 0255. Default value of 4.0.

  • strength This number represents the strength of the shadow's imprint. From 0255, the higher this number, the more contrast there will be. Default value of 2.0.

  • quality This number represents the number of times to apply the filter ranging from 015. Default value of 1.

  • inner If true, the glow will become an inner glow. Default value of false, creating an outer glow.

  • knockout The Boolean value controls whether the object having the filter applied to it will be transparent, true, or not, false.

Example:

This example will create a small blue square using the drawing API and apply the filter to it:

 import flash.filters.GlowFilter; //create the movie clip to display the filter var rec_mc:MovieClip = this.createEmptyMovieClip("rec_mc", 1); //move the rectangle towards the center of the stage rec_mc._x = rec_mc._y = 200; //draw a squar inside the movie clip rec_mc.lineStyle(0,0x000000,0); rec_mc.beginFill(0x397dce, 100); rec_mc.lineTo(100,0); rec_mc.lineTo(100,100); rec_mc.lineTo(0,100); rec_mc.lineTo(0,0); rec_mc.endFill(); //create the filter var myFilter:GlowFilter = new GlowFilter(0x000033, 75, 20, 20, 2, 3); //apply the filter rec_mc.filters = new Array(myFilter); 

Because the properties of this object match the parameters identically, they will be skipped.

Methods

clone

Availability: FP:8, AS:1.0

Generic Template: myFilter.clone()

Returns: GlowFilter

An exact copy of the GlowFilter will be returned.

Description:

This method will create a duplicate copy of the GlowFilter it is called on.

Example:

This example will create a filter, clone it, then walk through all the properties to see that they match:

 import flash.filters.GlowFilter; //create the filter var myFilter:GlowFilter = new GlowFilter(0x000033, 75, 20, 20, 2, 3); //apply the filter img_mc.filters = new Array(myFilter); //create a copy var myNewFilter:GlowFilter = myFilter.clone(); //walk through and display each property for(each in myNewFilter){     trace(each + ": " + myNewFilter[each]); } //output:clone: [type Function] //strength: 2 //blurY: 20 //blurX: 20 //knockout: false //inner: false //quality: 3 //alpha: 1 //color: 51 




Macromedia Flash Professional 8 Unleashed
Macromedia Flash Professional 8 Unleashed
ISBN: 0672327619
EAN: 2147483647
Year: 2005
Pages: 319

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net