Flash CS3 ドキュメンテーション |
|||
| ActionScript 2.0 リファレンスガイド > ActionScript クラス > Rectangle (flash.geom.Rectangle) > clone (Rectangle.clone メソッド) | |||
public clone() : Rectangle
元の Rectangle オブジェクトと x、y、width、および height の各プロパティの値が同じである、新しい Rectangle オブジェクトを返します。
対応バージョン : ActionScript 1.0、Flash Player 8
Rectangle - 元の Rectangle オブジェクトと x、y、width、および height の各プロパティの値が同じである、新しい Rectangle オブジェクト
次の例では、3 つの Rectangle オブジェクトを作成し、それらを比較します。rect_1 は、Rectangle コンストラクタを使用して作成されます。rect_2 は、rect_1 と等しい値に設定することにより作成されます。clonedRect は、rect_1 のクローンを作成することにより作成されます。rect_2 が rect_1 と等しいと評価された場合に、rect_1 と同じ値を含んでいても clonedRect は等しいと評価されないことに注意してください。
import flash.geom.Rectangle;
var rect_1:Rectangle = new Rectangle(1, 2, 4, 8);
var rect_2:Rectangle = rect_1;
var clonedRect:Rectangle = rect_1.clone();
trace(rect_1 == rect_2); // true
trace(rect_1 == clonedFilter); // false
for(var i in rect_1) {
trace(">> " + i + ": " + rect_1[i]);
>> toString: [type Function]
>> equals: [type Function]
>> union: [type Function]
>> intersects: [type Function]
>> intersection: [type Function]
>> containsRectangle: [type Function]
>> containsPoint: [type Function]
>> contains: [type Function]
>> offsetPoint: [type Function]
>> offset: [type Function]
>> inflatePoint: [type Function]
>> inflate: [type Function]
>> size: (x=4, y=8)
>> bottomRight: (x=5, y=10)
>> topLeft: (x=1, y=2)
>> bottom: 10
>> top: 2
>> right: 5
>> left: 1
>> isEmpty: [type Function]
>> setEmpty: [type Function]
>> clone: [type Function]
>> height: 8
>> width: 4
>> y: 2
>> x: 1
}
for(var i in clonedRect) {
trace(">> " + i + ": " + clonedRect[i]);
>> toString: [type Function]
>> equals: [type Function]
>> union: [type Function]
>> intersects: [type Function]
>> intersection: [type Function]
>> containsRectangle: [type Function]
>> containsPoint: [type Function]
>> contains: [type Function]
>> offsetPoint: [type Function]
>> offset: [type Function]
>> inflatePoint: [type Function]
>> inflate: [type Function]
>> size: (x=4, y=8)
>> bottomRight: (x=5, y=10)
>> topLeft: (x=1, y=2)
>> bottom: 10
>> top: 2
>> right: 5
>> left: 1
>> isEmpty: [type Function]
>> setEmpty: [type Function]
>> clone: [type Function]
>> height: 8
>> width: 4
>> y: 2
>> x: 1
}
rect_1、rect_2、および clonedRect の関係をさらに詳しく示すために、次の例では、rect_1 の x プロパティを変更します。x を変更することは、clone() メソッドによって、rect_1 を参照する代わりにその値に基づいて新しいインスタンスが作成されることを示します。
import flash.geom.Rectangle; var rect_1:Rectangle = new Rectangle(1, 2, 4, 8); var rect_2:Rectangle = rect_1; var clonedRect:Rectangle = rect_1.clone(); trace(rect_1.x); // 1 trace(rect_2.x); // 1 trace(clonedRect.x); // 1 rect_1.x = 10; trace(rect_1.x); // 10 trace(rect_2.x); // 10 trace(clonedRect.x); // 1
x (Rectangle.x プロパティ), y (Rectangle.y プロパティ), width (Rectangle.width プロパティ), height (Rectangle.height プロパティ)
このページに新しいコメントが追加された場合に、電子メールでの通知を希望する。 | コメントレポート
現在のページ: http://livedocs.adobe.com/flash/9.0_jp/main/00002078.html