Copy link to clipboard
Copied
I want to make a draggable mask inside Animate CC Canvas.
box is a movieClip that contains a vector black square.
bg is a movieClip that contains a bitmap that i want to apply the box as a mask to and drag around.
Both display on screen, but the dragBox is only draggable, but it won't mask the backgroundImage. What am I missing here?
var backgroundImage = new lib.bg();
backgroundImage.x = backgroundImage.y = 0;
stage.addChild(backgroundImage);
var dragBox = new lib.box();
dragBox.x = dragBox.y = 0;
stage.addChild(dragBox);
backgroundImage.mask = dragBox;
stage.update();
dragBox.addEventListener("pressmove", dragMe.bind(this));
function dragMe(evt) {
this.addChild(evt.currentTarget);
var p = this.globalToLocal(evt.stageX, evt.stageY);
evt.currentTarget.x = p.x;
evt.currentTarget.y = p.y;
}
Have something to add?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now