1 /**
  2 * MouseEvent by Grant Skinner. Dec 5, 2010
  3 * Visit http://easeljs.com/ for documentation, updates and examples.
  4 *
  5 *
  6 * Copyright (c) 2010 Grant Skinner
  7 * 
  8 * Permission is hereby granted, free of charge, to any person
  9 * obtaining a copy of this software and associated documentation
 10 * files (the "Software"), to deal in the Software without
 11 * restriction, including without limitation the rights to use,
 12 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 13 * copies of the Software, and to permit persons to whom the
 14 * Software is furnished to do so, subject to the following
 15 * conditions:
 16 * 
 17 * The above copyright notice and this permission notice shall be
 18 * included in all copies or substantial portions of the Software.
 19 * 
 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 22 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 24 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 25 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 27 * OTHER DEALINGS IN THE SOFTWARE.
 28 */
 29 
 30 
 31 
 32 /**
 33 * Constructs a new MouseEvent instance.
 34 * @param type The event type.
 35 * @param stageX The mouseX position relative to the stage.
 36 * @param stageY The mouseY position relative to the stage.
 37 * @class This is passed as the parameter to onPress, onMouseMove, onMouseUp, onMouseDown, and onClick handlers on 
 38 * DisplayObject instances.
 39 * By default, mouse events are disabled for performance reasons. In order to enabled them for a specified stage
 40 * set mouseEventsEnabled to true on your stage instance.
 41 * @see Stage#mouseEventsEnabled
 42 */
 43 function MouseEvent(type, stageX, stageY) {
 44   this.initialize(type, stageX, stageY);
 45 this.prototype;
 46 	
 47 // public properties:
 48 	/** The mouseX position on the stage. */
 49 	this.stageX = 0;
 50 	/** The mouseY position on the stage. */
 51 	this.stageY = 0;
 52 	/** The type of mouse event. This will be the same as the handler it maps to (onPress, onMouseDown, 
 53 		onMouseUp, onMouseMove, or onClick). 
 54 	*/
 55 	this.type = null;
 56 	/** For events of type "onPress" and "onMouseDown" only you can assign a handler to the onMouseMove 
 57 		property. This handler will be called every time the mouse is moved until the mouse is released. 
 58 		This is useful for operations like drag and drop. 
 59 	*/
 60 	this.onMouseMove = null;
 61 	/** For events of type "onPress" and "onMouseDown" only you can assign a handler to the onMouseUp property. 
 62 		This handler will be called a single time when the mouse is released anywhere over the page. This is useful for operations 
 63 		like drag and drop. 
 64 	*/
 65 	this.onMouseUp = null;
 66 	
 67 // constructor:
 68 	/** @private */
 69 	this.initialize = function(type, stageX, stageY) {
 70 		this.type = type;
 71 		this.stageX = stageX;
 72 		this.stageY = stageY;
 73 	}
 74 	
 75 // public methods:
 76 	/**
 77 	* Returns a clone of the MouseEvent instance.
 78 	*/
 79 	this.clone = function() {
 80 		return new MouseEvent(this.type, this.stageX, this.stageY);
 81 	}
 82 
 83 	/**
 84 	* Returns a string representation of this object.
 85 	*/
 86 	this.toString = function() {
 87 		return "[MouseEvent (type="+this.type+" stageX="+this.stageX+" stageY="+this.stageY+")]";
 88 	}
 89 	}