The BevelFilter Class
The BevelFilter class is designed to create bevel-image effects on objects.It is important when using this class to import it first at the beginning of your script, like this:
To instantiate a new instance of the BevelFilter class, use this code as a template:
import flash.filters.BevelFilter;
[View full width]var myFilter:BevelFilter = new BevelFilter(dist, angle, highlightColor, highlightAlpha,shadowColor, shadowAlpha, blurX, blurY, strength, quality, type, knockout);
- dist
The distance in pixels for the bevel to be offset. Default value of 4.0. - angle
The bevel's angle between 0 and 360. Default value of 45. - highlightColor
The highlight ARGB color of the bevel. Default value of 0x00ffffff. - highlightAlpha
The alpha of the highlight color in the bevel from 0 to 1. Default value of 1.0. - shadowColor
The shadow ARGB color of the bevel. Default value of 0x00000000. - shadowAlpha
The alpha of the shadow color in the bevel from 0 to 1. 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 bevel's imprint. From 0255, the higher this number, the more contrast there will be. Default value of 1. - 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 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:
[View full width]import flash.filters.BevelFilter;Because the properties of this object match the parameters identically, they will be skipped.
//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:BevelFilter = new BevelFilter(5, 45, 0x00ccff, 1, 0x000033, 1, 5, 5, 2, 3,"inner", false);
//apply the filter
rec_mc.filters = new Array(myFilter);
Methods
clone
Availability:2
FP:8, AS:1.0Generic Template :
myFilter.clone()Returns :
BevelFilterAn exact copy of the BevelFilter will be returned.Description: This method will create a duplicate copy of the BevelFilter it is called on.Example: This example will create a filter, clone it, and then walk through all the properties to see that they match:
[View full width]import flash.filters.BevelFilter;
//create the filter
var myFilter:BevelFilter = new BevelFilter(5, 45, 0x00ccff, 1, 0x000033, 1, 5, 5, 2, 3,"inner", false);
//create a copy
var myNewFilter:BevelFilter = myFilter.clone();
//walk through and display each property
for(each in myNewFilter){
trace(each + ": " + myNewFilter[each]);
}
//output:clone: [type Function]
//type: inner
//blurY: 5
//blurX: 5
//knockout: false
//strength: 2
//quality: 3
//shadowAlpha: 1
//shadowColor: 51
//highlightAlpha: 1
//highlightColor: 52479
//angle: 45
//distance: 5