CreateJS / EaselJS

The Easel Javascript library provides a full, hierarchical display list, a core interaction model, and helper classes to make working with the HTML5 Canvas element much easier.
http://createjs.com/
MIT License
8.13k stars 1.97k forks source link

The click event is not working properly #630

Open ghost opened 9 years ago

ghost commented 9 years ago

I added a click event on an object, It is working fine when I tap on my mouse pad but clicks doesn't seem to work. It sometimes takes 2-3 clicks for it to work.

This is my code. There's a video playing and the canvas is on top of it.

var o1 = new createjs.Shape();
o1.graphics.setStrokeStyle( 0 ).beginStroke( '#000' ).drawRect(81,117,234,41);
o1.alpha = 0;
var o1Hit = new createjs.Shape();
o1Hit.graphics.beginFill("#000").drawRect(81,117,234,41);
o1.hitArea = o1Hit;
options.addChild(o1);
options.update();

o1.on("click", function(evt) {
    videojs('sortedd', {}, function(){
    this.src({ type: "video/mp4", src: 'questions/question_1/Q394.mp4' });
    this.play();
    currentQuestion = 1;
    options.removeAllChildren();
    options.update();
    var audioElement = document.createElement('audio');
    audioElement.setAttribute('src', 'audio.mp3');
    audioElement.setAttribute('autoplay', 'autoplay');
    audioElement.load();
    audioElement.addEventListener("load", function() {
    audioElement.play();
    }, true);
   });
});
lannymcnie commented 8 years ago

Can you post a sample? It would also be good to know what browser/device(s) this happens in.