-
Notifications
You must be signed in to change notification settings - Fork 0
/
08-applying-events.html
83 lines (66 loc) · 2.64 KB
/
08-applying-events.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>ZIM Frame - Full Template</title>
<!-- Welcome to ZIM at http://zimjs.com - Code Interactive Media Pizzazz! -->
<!-- ZIM runs on the HTML Canvas powered by JavaScript and CreateJS http://createjs.com -->
<!-- Founded by Inventor Dan Zen - http://danzen.com - Canadian New Media Award Winner -->
<!-- ZIM is free to use. You can donate to help improve ZIM at http://zimjs.com/donate -->
<!-- as of ZIM 4.3.0 load createjs namespace first -->
<script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>
<script>var zon = true; // true for comments from zim code</script>
<script src="https://d309knd7es5f10.cloudfront.net/zim_4.7.3.js"></script><!-- add _doc to see code -->
<!-- use zimjs.com/code/distill for minified individual functions! -->
<script>
// SCALING OPTIONS
// scaling can have values as follows with full being the default
// "fit" sets canvas and stage to dimensions and scales to fit inside window size
// "outside" sets canvas and stage to dimensions and scales to fit outside window size
// "full" sets stage to window size with no scaling
// "tagID" add canvas to HTML tag of ID - set to dimensions if provided - no scaling
var scaling = "full"; // makes stage the window size but does not scale content
var width = null;
var height = null;
var color = "#ebcb35";
var frame = new zim.Frame(scaling, width, height, color); // see docs for more options and info
frame.on("ready", function() {
zog("ready from ZIM Frame");
var stage = frame.stage;
var stageW = frame.width;
var stageH = frame.height;
// put your code here (you can delete this code)
var circle = new zim.Circle(100, "hotpink");
circle.center(stage);
circle.cursor = "pointer";
var rect = new zim.Rectangle(100, 200, "blue");
rect.x = 200;
rect.y = 200;
var triangle = new zim.Triangle(200, 200, 200, "#3ad");
triangle.x = 1050;
triangle.y = 300;
stage.addChild(rect, triangle);
// triangle.outline();
circle.on("mouseover", animate);
// circle.off("click", animate);
rect.on("mouseover", animate);
// rect.off("click", animate);
triangle.on("mouseover", animate);
// triangle.off("click", animate);
function animate(e) {
e.target.animate({obj:{scale: 0.8}, time:200, rewind: true});
// var mouseoutEvent = this.on("mouseout", function() {
// this.color = "#ccc";
// stage.update();
// circle.off("mouseout". mouseoutEvent);
// })
stage.update();
}
stage.update();
}); // end of ready
</script>
</head>
<body>
<!-- canvas with id="myCanvas" is made by zim Frame -->
</body>
</html>