Skip to main content
Participant
October 9, 2017
Question

Draggable mask in Canvas easljs

  • October 9, 2017
  • 0 replies
  • 217 views

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;
}

    This topic has been closed for replies.