Search code examples
javascriptgoogle-chromecreatejs

Drag and drop doesn't work in chrome using EaselJS


I've been trying to implement some drag and drop functionality for a Bitmap in EaselJS. Anyways, it works just fine in Firefox and IE, but nothing happens when I try to run the code in Chrome. All of the code is local, as is the image.

Here's a brief overview of the relevant code:

     stage = new createjs.Stage("testCanvas");
     img = new createjs.Bitmap("img.png");
     stage.addChild(img);
     img.addEventListener("pressmove", function ( event ) {

        img.x = event.stageX;
        img.y = event.stageY;

    });

    stage.update();

Solution

  • Chrome does not allow access to pixel data on canvases that have been "tainted" by local images (security sandbox restriction). EaselJS relies on pixel data to provide accurate mouse interactions. Run your code from a local server (ex. MAMP) to test.