The GradientGlowFilter Class


The GradientGlowFilter Class

The GradientGlowFilter class is designed to create beveled gradient 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.GradientGlowFilter; 

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

[View full width]

var myFilter:GradientGlowFilter = new GradientGlowFilter(dist, angle, colors, alphas, ratios, blurX, blurY, strength, quality, type, knockout);

  • dist The distance in pixels for the glow to be offset between 08. Default value of 4.0.

  • colors An array of colors to use in the gradient.

  • alphas An array of alphas to use in the gradient.

  • ratios An array of ratios to use in the gradient.

  • 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 glow imprint. From 05, the higher this number, the more contrast. Default value of 1.0.

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

  • type This string represents the type of bevel to apply: inner, outer, or full. Default value of inner.

  • knockout The Boolean value controls whether the object having the filter applied to 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:

[View full width]

import flash.filters.GradientGlowFilter; //the arrays we need var colors:Array = [0xFFFFFF, 0x000033, 0x397dce, 0x00CCFF]; var alphas:Array = [0, .25, .5, 1]; var ratios:Array = [0, 60, 125, 255]; //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:GradientGlowFilter = new GradientGlowFilter (5, 45, colors, alphas, ratios, 30, 30, 2, 3, "outer"); //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: GradientGlowFilter

An exact copy of the GradientGlowFilter will be returned.

Description:

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

Example:

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

[View full width]

import flash.filters.GradientGlowFilter; //the arrays we need var colors:Array = [0xFFFFFF, 0xCCCCCC, 0x000000]; var alphas:Array = [1, 0, 1]; var ratios:Array = [0, 128, 255]; //create the filter var myFilter:GradientGlowFilter = new GradientGlowFilter (5, 45, colors, alphas, ratios, 30, 30, 2, 3, "outer"); //apply the filter img_mc.filters = new Array(myFilter); //create a copy var myNewFilter:GradientGlowFilter = myFilter.clone(); //walk through and display each property for(each in myNewFilter){ trace(each + ": " + myNewFilter[each]); } //output:clone: [type Function] //type: outer //knockout: false //strength: 2 //quality: 3 //blurY: 30 //blurX: 30 //ratios: 0,128,255 //alphas: 1,0,1 //colors: 16777215,13421772,0 //angle: 45 //distance: 5




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