最简单的方法是:
在阶段400x400上的我有rect 200x200,在rect里面有几个mc对象。我可以拖延删除StartDrag并添加200x200作为此移动的限制,但是如何在拖动obejct时可以这样做,它们可以在rect的边界附近“可见”,换句话说,如果我将圆圈拖到200x200矩形中如何使“消失”部分当它接触200x200 rect的边界时该圆圈的哪个?
答案 0 :(得分: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;