forked from CreateJS/EaselJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMovieClip.html
executable file
·65 lines (53 loc) · 2.08 KB
/
MovieClip.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>EaselJS Example: MovieClips</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>
</head>
<body onload="init()">
<header class="EaselJS">
<h1>MovieClip</h1>
<p>Demonstrates creating a <code>MovieClip</code> using JavaScript. Each
shape instance tweened, and then the tweens are
added to the <code>MovieClip.timeline</code>. The timeline can then be
controlled by JavaScript. Requires <code>TweenJS</code>.</p>
</header>
<div>
<canvas id="testCanvas" width="960" height="400"></canvas>
</div>
<script src="../lib/easeljs-NEXT.combined.js"></script>
<!-- We also provide hosted minified versions of all CreateJS libraries.
http://code.createjs.com -->
<!-- MovieClip is not included in the core library, and is dependent on TweenJS -->
<script src="../_assets/libs/tweenjs-NEXT.min.js"></script>
<script src="../lib/movieclip-NEXT.combined.js"></script>
<script id="editable">
function init() {
var stage = new createjs.Stage("testCanvas");
createjs.Ticker.addEventListener("tick", stage);
// Create the MovieClip
var mc = new createjs.MovieClip(null, 0, true, {start: 0, middle: 40});
stage.addChild(mc);
// Create the States. Each state is just a circle shape.
var state1 = new createjs.Shape(
new createjs.Graphics().beginFill("#999999")
.drawCircle(100, 200, 50));
var state2 = new createjs.Shape(
new createjs.Graphics().beginFill("#6699FF")
.drawCircle(100, 200, 50));
// Create a tween for each shape, animating from one side to the other.
mc.timeline.addTween(
createjs.Tween.get(state1)
.to({x: 0}).to({x: 760}, 40).to({x: 0}, 40));
mc.timeline.addTween(
createjs.Tween.get(state2)
.to({x: 760}).to({x: 0}, 40).to({x: 760}, 40));
// Play the animation starting from the middle. See the MovieClip constructor above where the labels are specified.
mc.gotoAndPlay("middle");
}
</script>
</body>
</html>