Copy link to clipboard
Copied
Hello,
I have read almost all the articles in this forum about the touch function and I can't find a solution that works. I have the following code that doesn't work on tablets. Could someone please tell me where is my error? I'm new to HTML5 canvas.
Thanks in advance for any answer.
createjs.Touch.enable(stage, false, true);
var m_X;
var m_Y;
this.movieClip.addEventListener("mousedown", maFonction.bind(this));
function maFonction(evt) {
var st = this.globalToLocal(evt.stageX, evt.stageY);
var c_X = st.x;
var c_Y = st.y;
var d_X = this.movieClip.x;
var d_Y = this.movieClip.y;
m_X = (d_X - c_X);
m_Y = (d_Y - c_Y);
}
this.movieClip.addEventListener("pressmove", maFonction2.bind(this));
function maFonction2(evt) {
var st = this.globalToLocal(evt.stageX, evt.stageY);
var c_X = st.x;
var c_Y = st.y;
var mt1 = m_X;
var mt2 = m_Y;
var z_X = Math.round(c_X + mt1);
var z_Y = Math.round(c_Y + mt2);
this.movieClip.x = z_X;
this.movieClip.y = z_Y;
stage.update(event);
};
Copy link to clipboard
Copied
i don't see a code problem. you should be able to drag and drop movieClip (though nothing happens when you drop).
what do you expect to occur that you fail to see?
Copy link to clipboard
Copied
In fact, I just found out by publishing on the Internet that this code works. The problem came from the "adaptive view" of my browsers that don't work (which is necessarily annoying for the rest).
Thank you for your answer. The subject is closed.
(Unless you have an idea how to fix the browser's adaptive console, please ?).
Copy link to clipboard
Copied
you're welcome.