-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCjsPrototypes.js
129 lines (118 loc) · 3.98 KB
/
CjsPrototypes.js
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
/*
@version: 1.1.2 // Major. Minor. Bugfix
@author: howeller, [email protected]
@desc: Animation Prototypes to extend CjsFun class.
@usage:
* Declare protoypes before CjsFun instantiation either in the HTML <script> or Frame0
CjsFun.prototype.slideIn=function(_mc, _sp, _delay, _ease){
this.initMc(_mc);
_options=_options||{};
var delay = _delay||0,
sp = _options.sp||0.3,
ease = _options.ease||this.globalEase,//createjs.Ease.quadOut;//
startX = _options.startX||(0-_mc.nominalBounds.width);
_mc.x = startX;
createjs.Tween.get(_mc, {override:true}).wait(delay*1000).to({x:_mc.stageX}, sp*1000, myEase);
}
* Instantiate CjsFun on Frame 0
this.fun = new CjsFun(this);
* Execute on any frame:
this.fun.slideIn( this.mc1, 1.5, {sp:1.1, createjs.Ease.BackIn});
*/
// console.log("CjsFun.prototype! "+this);
/*
Slides down mc from -= mc height or specified startY
*/
CjsFun.prototype.slideDown=function(_mc, _delay, _options){
console.log("slideDown! "+_mc);
this.initMc(_mc);
_options=_options||{};
var delay = _delay||0,
sp = _options.sp||0.3,
ease = _options.ease||this.globalEase,//createjs.Ease.quadOut;//
startY = _options.startY||(_mc.y-_mc.nominalBounds.height);
_mc.y = startY;
createjs.Tween.get(_mc, {override:true}).wait(delay*1000).to({y:_mc.stageY}, sp*1000, ease);
}
/*
Slides in MC from offstage left or variable startX
*/
CjsFun.prototype.slideIn=function(_mc, _delay, _options){
this.initMc(_mc);
_options=_options||{};
var delay = _delay||0,
sp = _options.sp||0.3,
ease = _options.ease||this.globalEase,//createjs.Ease.quadOut;//
startX = _options.startX||(0-_mc.nominalBounds.width);
_mc.x = startX;
createjs.Tween.get(_mc, {override:true}).wait(delay*1000).to({x:_mc.stageX}, sp*1000, myEase);
}
/*
Slides in MC from variable startY
*/
CjsFun.prototype.slideUp=function(_mc, _delay, _options){
this.initMc(_mc);
_options=_options||{};
var delay = _delay||0,
sp = _options.sp||0.3,
ease = _options.ease||this.globalEase,//createjs.Ease.quadOut;//
startY = _options.startY||(canvas.height);
_mc.y = startY;
createjs.Tween.get(_mc, {override:true}).wait(delay*1000).to({y:_mc.stageY}, sp*1000, ease);
}
/*
Tweens out mc to variable x position
*/
CjsFun.prototype.slideOut=function(_mc, _delay, _options){
this.initMc(_mc);
_options=_options||{};
var delay = _delay||0,
sp = _options.sp||0.3,
ease = _options.ease||this.globalEase,//createjs.Ease.quadOut;//
endX = _options.endX||(0-_mc.nominalBounds.width);
// console.log("< slideOut _sp"+_sp+" endX:"+endX);
createjs.Tween.get(_mc, {override:true}).wait(delay).to({x:endX}, sp, myEase);
}
/*
Tweens scale to from 0 to size on stage.
*/
CjsFun.prototype.scaleIn=function(_mc, _delay, _options){
this.initMc(_mc,{useStageReg:true});
_options=_options||{};
var delay = _delay||0,
sp = _options.sp||0.3,
ease = _options.ease||this.globalEase;//createjs.Ease.quadOut;//
// console.log("scaleIn! "+_mc.scaleX+" stageScale:"+stageScale);
_mc.scaleX = _mc.scaleY = 0;
createjs.Tween.get(_mc,{override:true}).wait(delay*1000).to({scaleX:_mc.stageScaleX,scaleY:_mc.stageScaleY}, sp*1000, ease);
}
/*
Tweens scale to 0
*/
CjsFun.prototype.scaleOut=function(_mc, _delay, _options){
this.initMc(_mc);
_options=_options||{};
var delay = _delay||0,
sp = _options.sp||0.3,
ease = _options.ease||this.globalEase;//createjs.Ease.quadOut;//
// console.log("scaleOut! "+_mc.scaleX+" stageScale:"+stageScale);
createjs.Tween.get(_mc,{override:true}).wait(delay*1000).to({scaleX:0,scaleY:0}, sp*1000, ease);
}
/*
ONLY WORKS FOR MCs ON MAIN TIMELINE. Returns instance names on movieclips. Name property does not work.
*/
/*createjs.DisplayObject.prototype.getName = function() {
if (this._cacheName === undefined) {
var parent = exportRoot;//this.parent;
var keys = Object.keys(parent);
var len = keys.length;
while (--len) {
if (parent[keys[len]] === this) {
this._cacheName = keys[len];
break;
}
}
}
return this._cacheName;
}*/