mousedown event in CreateJS? - Javascript Canvas

Javascript examples for Canvas:Mouse

Description

mousedown event in CreateJS?

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.createjs.com/createjs-2015.05.21.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*from ww  w. j  av  a2s  .  co  m*/
var c=createjs;
var stage = new c.Stage("test");
var container = new c.Container();
container.x = container.y = 100;

container.mouseChildren = false;
container.on("mousedown", function() {
    container.removeChild(a);
    container.addChild(b);
});
container.on("pressmove", function(evt) {
    this.x = evt.stageX;
    this.y = evt.stageY;
});
var a = container.a = new c.Shape();
a.graphics.f("red").dc(0,0,50);
var b = container.b = new c.Shape();
b.graphics.f("blue").dc(0,0,50);
container.addChild(a);
stage.addChild(container);
c.Ticker.on("tick", stage);
    }

      </script> 
   </head> 
   <body> 
      <canvas id="test" width="500" height="400"></canvas>  
   </body>
</html>

Related Tutorials