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 blueText = stage.text(70, 55, 'Click on this TEXT');
4
blueText.style({fontStyle: 'italic', fontSize: '18px', color: '#2196F3', hAlign: 'center'});
5
6
var rect = stage.rect();
7
rect.setBounds(blueText.getBounds());
8
rect.fill('#FFEBEE 0.00001');
9
rect.stroke(null);
10
11
acgraph.events.listen(rect, 'mouseOver', function (e) {
12
blueText.style({color: '#4CAF50'});
13
});
14
15
acgraph.events.listen(rect, 'mouseOut', function (e) {
16
blueText.style({color: '#2196F3'});
17
});
18
19
acgraph.events.listenOnce(rect, 'click', function (e) {
20
blueText.text('You can\'t click here anymore');
21
blueText.style({color: '#F44336'});
22
23
rect.setBounds(blueText.getBounds());
24
25
// Removes all listeners.
26
acgraph.events.removeAll(rect);
27
});