Zac Zac - 6 months ago 15
Javascript Question

In EaselJS, how can I get a boolean saying if the mouse is down?

I'm making a kind of drawing thing to learn CreateJS, and at the moment I have the mouse drawing a line. The only problem is, the line is constantly being drawn. What I want is to check every frame if the left mouse button is down, and if it is, then I would draw a new line behind the mouse. Is there any way to do this? I have been looking at the event listeners on the stage but I couldn't seem to get that working. How should I do this?


EaselJS does not monitor or store the mouse up/down value, but rather responds to mousedown/mouseup events. You could fairly easily just listen to stagemousedown and stagemouseup events on the EaselJS stage, and store your own value.

Alternately, you could use these events to start and end draw routines. For example, the pressmove event only fires when the mouse has been pressed on something, and is currently moving.

Hope that helps.