-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathButtonHelper.html
executable file
·82 lines (62 loc) · 2.32 KB
/
ButtonHelper.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>EaselJS Example: Rollovers and Drag & Drop</title>
<link href="../_assets/css/shared.css" rel="stylesheet" type="text/css"/>
<link href="../_assets/css/examples.css" rel="stylesheet" type="text/css"/>
<script src="../_assets/js/examples.js"></script>
<script src="../lib/easeljs-NEXT.js"></script>
<script src="../_assets/libs/tweenjs-NEXT.min.js"></script>
<script src="../_assets/art/VectorButton.js"></script>
<script id="editable">
var stage;
function init() {
examples.showDistractor();
// create stage and point it to the canvas:
stage = new createjs.Stage("testCanvas");
// enable touch interactions if supported on the current device:
createjs.Touch.enable(stage);
// enable mouse over / out events, required for button rollovers
stage.enableMouseOver(10);
// load the source image:
var image = new Image();
image.src = "../_assets/art/spritesheet_button.png";
image.onload = handleImageLoad;
}
function handleImageLoad(evt) {
examples.hideDistractor();
// spritesheet "bitmap" button:
var spriteSheet = new createjs.SpriteSheet({
images: [evt.target],
frames: {width: 300, height: 100},
animations: { out: 0, over: 1, down: 2 }
});
var bitmapButton = new createjs.Sprite(spriteSheet, "up");
stage.addChild(bitmapButton).set({x: 50, y: 50});
var bitmapHelper = new createjs.ButtonHelper(bitmapButton);
// movieclip "vector" button:
var vectorButton = new lib.VectorButton();
stage.addChild(vectorButton).set({x: 400, y: 50});
var vectorHelper = new createjs.ButtonHelper(vectorButton);
bitmapButton.on("click", function () {
vectorHelper.enabled = !vectorHelper.enabled;
vectorButton.alpha = 0.5 + vectorHelper.enabled * 0.5;
});
createjs.Ticker.addEventListener("tick", stage);
}
</script>
</head>
<body onload="init();">
<header class="EaselJS">
<h1>ButtonHelper Example</h1>
<p>Shows how to use a <code>ButtonHelper</code> with <code>Sprite</code> or
<code>MovieClip</code> instances (or anything with a
<code>gotoAndStop()</code> method). Clicking the bitmap button toggles
<code>enabled</code> on the vector <code>ButtonHelper</code></p>
</header>
<div>
<canvas id="testCanvas" width="960" height="400"></canvas>
</div>
</body>
</html>