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
function customListener(e) {
11
counter--;
12
smallText.text("You have " + counter + " clicks.");
13
if (counter == 0) {
14
// Removes a listener.
15
largeText.unlisten("click", customListener);
16
17
largeText.style({color: "#F44336"});
18
smallText.text("You have no more clicks");
19
}
20
}
21
22
largeText.listen("click", customListener);