文章说明:为了方便我自己查找easeljs的所有事件,所以我从easeljs的文档里抄过来加上自己的翻译,会慢慢补全,漏了的,错了的,评论一下我会补上去哦。(不确定翻译对不对的地方我会留着原文。)
easeljs事件默认是不支持touch设备的,需要这样才可以 var stage = new createjs.Stage("canvasId"); createjs.Touch.enable(stage);
继承自 EventDispatcher A shortcut method for using addEventListener that makes it easier to specify an execution scope, have a listener only run once, associate arbitrary data with the listener, and remove the listener. This method works by creating an anonymous wrapper function and subscribing it with addEventListener. The wrapper function is returned for use with removeEventListener (or off). IMPORTANT: To remove a listener added with on, you must pass in the returned wrapper function as the listener, or use remove. Likewise, each time you call on a NEW wrapper function is subscribed, so multiple calls to on with the same params will create multiple listeners. Example
var listener = myBtn.on("click", handleClick, null, false, {count:3});
function handleClick(evt, data) {
data.count -= 1;
console.log(this == myBtn); // true - scope defaults to the dispatcher
if (data.count == 0) {
alert("clicked 3 times!");
myBtn.off("click", listener);
// alternately: evt.remove();
}
}
Parameters:
type String The string type of the event. listener Function | Object An object with a handleEvent method, or a function that will be called when the event is dispatched. [scope] Object optional The scope to execute the listener in. Defaults to the dispatcher/currentTarget for function listeners, and to the listener itself for object listeners (ie. using handleEvent). [once=false] Boolean optional If true, the listener will remove itself after the first time it is triggered. [data] optional Arbitrary data that will be included as the second parameter when the listener is called. [useCapture=false] Boolean optional For events that bubble, indicates whether to listen for the event in the capture or bubbling/target phase. Returns:
Function: Returns the anonymous function that was created and assigned as the listener. This is needed to remove the listener later using .removeEventListener.
继承自 DisplayObject 当此对象被add到其它容器对象时触发
继承自 DisplayObject 加入版本 0.6.0 在用户按下左键并在此对象上松开左键后触发。
继承自 DisplayObject 加入版本 0.6.0 当用户在此对象上双击左键后触发。
定义于 stage 加入版本 0.7.0 每次显示列表被绘制到canvas后并且restore过canvas context后触发。 Dispatched each update immediately after the display list is drawn to the canvas and the canvas context is restored.
定义于 stage
加入版本 0.7.0
在清除画布和绘制显示列表之前触发。可以在调用event
对象上使用preventDefault
取消这次绘制。
Dispatched each update immediately before the canvas is cleared and the display list is drawn to it. You can call preventDefault on the event object to cancel the draw.
继承自 DisplayObject 加入版本 0.6.0 用户在此对象上按下左键后触发。
定义于 stage 加入版本 0.7.0 当鼠标指针从canvas区域外(mouseInBounds == true)移进canvas区域(mouseInBounds == false)后触发。这是目前唯一非点击的鼠标输入事件。
定义于 stage 加入版本 0.7.0 当鼠标从canvas区域内(mouseInBounds == true)移出(mouseInBounds == false)后触发。这是目前唯一非点击的鼠标输入事件。(我也不知道为何这里的mouseInBounds和上面的相反,看原文吧)
继承自 DisplayObject
加入版本 0.6.0
当用户鼠标从该对象的任意一个子项离开后触发。这个事件一定要启用enableMouseOver
。另请参阅rollout
。(写好rollout
后如果我还记得这里,会把这个链接弄好)
继承自 DisplayObject
加入版本 0.6.0
当用户鼠标进入该对象的任意一个子项后触发。这个事件一定要启用enableMouseOver
。另请参阅rollout
。(写好rollout
后如果我还记得这里,会把这个链接弄好)
继承自 DisplayObject
加入版本 0.7.0
在此对象上发生了mousedown
事件后,无论鼠标是否移动,pressmove
事件都会持续发生在此对象上,直到松开鼠标按钮。这事件在拖拽和类似的需求里很有用。
(如果stage上加了这个事件侦听,当stage上什么元素都没有时,这个是无效的,需要用stagemousemove
)
继承自 DisplayObject
加入版本 0.7.0
在此对象上发生了mousedown
事件后,松开鼠标会触发。这事件在拖拽和类似的需求里很有用。
继承自 DisplayObject 当此对象从它的父对象上移除后会触发。
继承自 DisplayObject
加入版本 0.7.0
这个事件和mouseout
很像,但有这些不同:它不冒泡,而且它把该对象的内容认为是一个整体。
例如,myContainer
包含着两个有重叠部分的子项:shapeA
和shapeB
。用户移动他的鼠标到shapeA
上,然后直接移到shapeB
上,然后离开他们俩。如果myContainer
有Mouseout:event
,会收到两个事件,每个事件指向一个子元素:
shapeA
时target=shapeA
shapeB
时target=shapeB
然而当事件换成rollout
,只会在离开myContainer
时才会触发事件(不仅仅是离开shapeB
),target=myContainer
。这个事件一定要启用enableMouseOver
。
(jquery也有这样的,但是我忘记jquery中哪个是只离开父对象才触发了。)
继承自 DisplayObject
加入版本 0.7.0
这个事件和mouseover
很像,不同之处跟rollout
和mouseout
的不同之处是一样的。这个事件一定要启用enableMouseOver
。
定义于 stage 加入版本 0.6.0 用户在canvas上按下左键后触发。
定义于 stage 加入版本 0.6.0 当用户在canvas上移动鼠标时持续触发。
定义于 stage
加入版本 0.6.0
当用户在stage的某处按下左键,然后在页面中能接收事件的任意一处(不同浏览器有些不同)松开左键。可以使用mouseInBounds
检查鼠标是否在stage
范围内。
继承自 DisplayObject: tick:642 加入版本 0.6.0 Dispatched on each display object on a stage whenever the stage updates. This occurs immediately before the rendering (draw) pass. When update is called, first all display objects on the stage dispatch the tick event, then all of the display objects are drawn to stage. Children will have their Tick:event event dispatched in order of their depth prior to the event being dispatched on their parent. Event Payload:
Defined in tickend:294 Available since 0.7.0 Dispatched each update immediately after the tick event is propagated through the display list. Does not fire if tickOnUpdate is false. Precedes the "drawstart" event.
Defined in tickstart:287 Available since 0.7.0 Dispatched each update immediately before the tick event is propagated through the display list. You can call preventDefault on the event object to cancel propagating the tick event.