Skip to main content
Inspiring
September 4, 2020
Question

Tactile problem

  • September 4, 2020
  • 1 reply
  • 245 views

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

 

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    September 5, 2020

    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?

    Inspiring
    September 5, 2020

    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 ?).

    kglad
    Community Expert
    Community Expert
    September 5, 2020

    you're welcome.