0

これを行う最も簡単な方法は次のとおりです。

ステージ 400x400 には rect 200x200 があり、rect 内にはいくつかの mc オブジェクトがあります。StartDrag をドラッグ アンド ドロップして、この動きの制限として 200x200 を追加できますが、オブジェクトをドラッグすると、四角形の境界線のすぐ近くで「見える」ようにする方法、つまり、円を 200x200 の四角形にドラッグした場合の作成方法200x200 rectの境界に触れると、その円の一部が「消える」?

4

1 に答える 1

4

円にマスクを追加する必要があります。上記のシナリオの例を次に示します。

var squareBG:Shape = new Shape();
squareBG.graphics.beginFill(0);
squareBG.graphics.drawRect(0,0,200,200);
squareBG.graphics.endFill();
addChild(squareBG);

var circle:Sprite = new Sprite();
circle.graphics.beginFill(0xFF0000);
circle.graphics.drawCircle(0,0,100);
circle.graphics.endFill();
circle.y = 125;
addChild(circle);

var circle2:Sprite = new Sprite();
circle2.graphics.beginFill(0xFFFF00);
circle2.graphics.drawCircle(0,0,100);
circle2.graphics.endFill();
addChild(circle2);
circle2.x = 150;

var myMask:Shape = new Shape();
myMask.graphics.copyFrom(squareBG.graphics);    
addChild(myMask);

var myMask2:Shape = new Shape();
myMask2.graphics.copyFrom(squareBG.graphics);    
addChild(myMask2);

circle.mask = myMask;
circle2.mask = myMask2;
于 2012-08-03T17:18:06.330 に答える