ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > DropShadowFilter (flash.filters.DropShadowFilter) > clone (DropShadowFilter.clone method) | |||
public clone() : DropShadowFilter
Returns a copy of this filter object.
Availability: ActionScript 1.0; Flash Player 8
DropShadowFilter - A new DropShadowFilter instance with all the properties of the original one.
The following example creates three DropShadowFilter objects and compares them; filter_1 is created by using the DropShadowFilter 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.DropShadowFilter;
var filter_1:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false);
var filter_2:DropShadowFilter = filter_1;
var clonedFilter:DropShadowFilter = 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]
// >> hideObject: false
// >> strength: 1
// >> blurY: 16
// >> blurX: 16
// >> knockout: false
// >> inner: false
// >> quality: 3
// >> alpha: 0.8
// >> color: 0
// >> angle: 45
// >> distance: 15
}
for(var i in clonedFilter) {
trace(">> " + i + ": " + clonedFilter[i]);
// >> clone: [type Function]
// >> hideObject: false
// >> strength: 1
// >> blurY: 16
// >> blurX: 16
// >> knockout: false
// >> inner: false
// >> quality: 3
// >> alpha: 0.8
// >> color: 0
// >> angle: 45
// >> distance: 15
}
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.DropShadowFilter; var filter_1:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, 0.8, 16, 16, 1, 3, false, false, false); var filter_2:DropShadowFilter = filter_1; var clonedFilter:DropShadowFilter = 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
|
|
|
|