-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathtest.html
61 lines (56 loc) · 1.88 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="../juggle-help/dist/juggle-help.js" type="text/javascript"></script>
<script src="../juggle-event/dist/juggle-event.js" type="text/javascript"></script>
<script type="text/javascript">
//继承EventDispatcher
function DisplayObj() {
this.parent = null;
this.isDisplayObject = true;
juggle.EventDispatcher.apply(this);
this.toString = function () {
return 'im DisplayObj';
}
}
//继承DisplayObj
function DisplayObjContainer() {
DisplayObj.apply(this);
this.addChild = function (child) {
child.parent = this;
};
this.removeChild = function (child) {
child.parent = null;
};
this.toString = function () {
return 'im DisplayObjContainer';
}
}
//关注事件的函数类
function Class1() {
this.operate = function (event, data) {
this;
alert(event.mCurrentTarget.toString());
};
}
window.onload = function () {
//创建DisplayObj对象
var obj = new DisplayObj();
//创建DisplayObjContainer对象
var container = new DisplayObjContainer();
//将container是obj的容器
container.addChild(obj);
//添加监听
var clazz = new Class1();
obj.addEventListener("aaa", clazz.operate, clazz);
container.addEventListener("aaa", clazz.operate, clazz);
//发布事件
obj.dispatchEventWith("aaa", true, "bbb");
}
</script>
</head>
<body>
</body>
</html>