• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

HTML5 touch event with createjs.Touch, getting double events.

Participant ,
Mar 12, 2021 Mar 12, 2021

Copy link to clipboard

Copied

My code uses the stagemousedown and stagemousemove events along with other events such as buttons.

I have code to allow createJS to handle touch events:


// Enable touch events on this stage

        createjs.Touch.enable(stage, false, true);

 

//   Don't let the stage to automatically prevent default touch events

        stage.preventSelection = false;

 

  //    And to prevent default events in the stagemousedown I have 

      event.nativeEvent.preventDefault();

My problem is now any buttons have a double event, (click is fired twice when I press a button).

 

TOPICS
Code , How to

Views

439

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 12, 2021 Mar 12, 2021

what does that mean?  you can't play part of a frame.

 

either the frame containing your handler executes more than once or it does not.  and if the frame executes more than once, you need to prevent re-execution of the listener. eg,

 

if(!alreadyExecuted){

alreadyExecuted=true;

yourwhatever.addEventListener("touchlistener",f);

}

Votes

Translate

Translate
Community Expert ,
Mar 12, 2021 Mar 12, 2021

Copy link to clipboard

Copied

is the code executed twice?  ie, the frame containing the code plays twice?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 12, 2021 Mar 12, 2021

Copy link to clipboard

Copied

Not the entire frame, no.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 12, 2021 Mar 12, 2021

Copy link to clipboard

Copied

LATEST

what does that mean?  you can't play part of a frame.

 

either the frame containing your handler executes more than once or it does not.  and if the frame executes more than once, you need to prevent re-execution of the listener. eg,

 

if(!alreadyExecuted){

alreadyExecuted=true;

yourwhatever.addEventListener("touchlistener",f);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines