Animate CC Masking in the Actions Panel?
Hi,
I'm trying to recreate a page-turn in the HTML-5 canvas. This involves dragging the corner of a page across the canvas and revealing the page beneath. In order to this I have some javascript code
However! I don't seem to be able to make the lineSymbol movieclip into a mask?
I also have an issue with the dragger not aligning to the lineSymbol. However, this feels like an issue I can fix.
The main thing is making the lineSymbol a mask. If I mask it in Animate CC, the javascript can't find it????
Any help much appreciated, I've scoured the internet but not found anything as yet....
var pageWidth = this.bookPage.nominalBounds.width;
var pageLeft = this.bookPage.x;
var pageRight = this.bookPage.x + pageWidth;
var pageHeight = this.bookPage.nominalBounds.height;
var pageTop = this.bookPage.y;
var pageBottom = this.bookPage.y + pageHeight;
var lineSymbol = this.line
var dragger = this.dragger
dragger.on("pressmove", function (evt) {
//this means that the mouse position is responsive to the size of the canvas which scales according to the size of the browser window or if viewed on iPad/iPhone
var mousePosition = stage.globalToLocal(evt.stageX, evt.stageY);
evt.currentTarget.x = mousePosition.x
evt.currentTarget.y = mousePosition.y
//this makes x-coord of the line equal to that of the mouse
lineSymbol.x=evt.currentTarget.x
//this says if the line is dragged beyond the page edge, it stays at the page edge and if the line is dragged beyond the page spine, it stays at the page spine
if (lineSymbol.x > pageRight) {
lineSymbol.x = pageRight;
} else if (lineSymbol.x < pageLeft) {
lineSymbol.x = pageLeft;
}
//this says if the line is dragged above the page top, it stays at the top edge and if the line is dragged below the page bottom, it stays at the bottom
if (evt.currentTarget.y > pageBottom) {
evt.currentTarget.y = pageBottom;
} else if (evt.currentTarget.y < pageTop) {
evt.currentTarget.y = pageTop;
}
lineSymbol.x=evt.currentTarget.x
lineSymbol.rotation = 45 * ((lineSymbol.x - pageLeft) / pageWidth);
stage.update(); //much smoother because it refreshes the screen on pixel movement not frame
})
Thanks,
Rob
