ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > ConvolutionFilter (flash.filters.ConvolutionFilter) > clone (ConvolutionFilter.clone method) | |||
public clone() : ConvolutionFilter
Returns a copy of this filter object.
Availability: ActionScript 1.0; Flash Player 8
ConvolutionFilter - A new ConvolutionFilter instance with all the same properties as the original one.
The following example creates three ConvolutionFilter objects and compares them: filter_1 is created by using the ConvolutionFilter 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.ConvolutionFilter;
var filter_1:ConvolutionFilter = new ConvolutionFilter(3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9);
var filter_2:ConvolutionFilter = filter_1;
var clonedFilter:ConvolutionFilter = 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]
// >> alpha: 0
// >> color: 0
// >> clamp: true
// >> preserveAlpha: true
// >> bias: 0
// >> divisor: 9
// >> matrix: 1,1,1,1,1,1,1,1,1
// >> matrixY: 3
// >> matrixX: 3
}
for(var i in clonedFilter) {
trace(">> " + i + ": " + clonedFilter[i]);
// >> clone: [type Function]
// >> alpha: 0
// >> color: 0
// >> clamp: true
// >> preserveAlpha: true
// >> bias: 0
// >> divisor: 9
// >> matrix: 1,1,1,1,1,1,1,1,1
// >> matrixY: 3
// >> matrixX: 3
}
To further demonstrate the relationships between filter_1, filter_2, and clonedFilter the following example modifies the bias property of filter_1. Modifying bias demonstrates that the clone() method creates a new instance based on values of filter_1 instead of pointing to them in reference.
import flash.filters.ConvolutionFilter; var filter_1:ConvolutionFilter = new ConvolutionFilter(3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9); var filter_2:ConvolutionFilter = filter_1; var clonedFilter:ConvolutionFilter = filter_1.clone(); trace(filter_1.bias); // 0 trace(filter_2.bias); // 0 trace(clonedFilter.bias); // 0 filter_1.bias = 20; trace(filter_1.bias); // 20 trace(filter_2.bias); // 20 trace(clonedFilter.bias); // 0
|
|
|
|