HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
var stage = acgraph.create("container");
2
3
var largeText = stage.text(70, 55, "Click on this TEXT.");
4
largeText.style({fontStyle: "italic", fontSize: "18px", color: "#2196F3", hAlign: "middle"});
5
6
var smallText = stage.text(70, 75, "You have 3 clicks.");
7
8
var counter = 3;
9
10
var listenerKey;
11
12
function customListener(e) {
13
counter--;
14
smallText.text("You have " + counter + " clicks.");
15
if (counter == 0) {
16
// Removes an event listener.
17
largeText.unlistenByKey(listenerKey);
18
largeText.style({color: "#F44336"});
19
smallText.text("You have no more clicks");
20
}
21
}
22
23
listenerKey = largeText.listen("click", customListener);