Copy link to clipboard
Copied
I've created an html5 canvas file in Animate CC and I can't seem to get it to respond to touches when run on a touch screen device. I've created a stripped down file to demonstrate the issue.
Every other post I've found online has been resolved with createjs.Touch.enable(stage), however, this doesn't enable touch for me (and it returns false). I've also included adding a touchstart event listener but this doesn't help either.
I've also attempted this to no effect.
To debug in the console I'm using chrome in device emulation mode. In Animate CC, centre stage and make responsive are both turned off in the publish settings.
Results from the example code below:
Any idea where I'm going wrong? Animate CC is completely up to date and createJS is v1.0.0
Expected behaviour is that the touchstart or mousedown handler is fired when the touch starts just like when using a mouse.
console.log("Enable touch: "+createjs.Touch.enable(stage) ); // returns false
ball = this.ball_mc;
// mouse mouse event
ball.on("mousedown", function(event) {
console.log("mouse down");
ball.x += 10;
});
// finger down event
ball.addEventListener("touchstart", function mouseDownHandler(e) {
console.log("finger down");
ball.x += 10;
});
Thanks in advance! - you'll be a lifesaver if you know what's going on or a workaround!
Dale.
Copy link to clipboard
Copied
Hi.
Your code seems to be correct. Do you have a preview link or an FLA for us to investigate?
Regards,
JC
Copy link to clipboard
Copied
Thanks JoãoCésar !
I forgot to update this, sorry.
In prepping the file for you I thought I better test it on device and it turns out that while I did my initial test on a touch device, I hadn't since, and had assumed that Chrome dev tools touch device emulator was acurate. Turns out it's not!
So, word of warning to anyone else, in regard to this feature, chrome dev tools doesn't send a mouse down event on touch and thus doesn't acurately emulate a touch device.
My file works on iPad and iPhone!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now