Rev 20 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 20 | Rev 11521 | ||
---|---|---|---|
Line 8... | Line 8... | ||
8 | */ |
8 | */ |
9 | 9 | ||
10 | function TextAnimation(x,y,text,animBy,dlyr){ |
10 | function TextAnimation(x,y,text,animBy,dlyr){ |
11 | this.EventObject = EventObject; |
11 | this.EventObject = EventObject; |
12 | this.EventObject(); |
12 | this.EventObject(); |
13 | 13 | ||
14 | this._chars=[]; |
14 | this._chars=[]; |
15 | this._lyrPool=[]; |
15 | this._lyrPool=[]; |
16 | this._text=text; |
16 | this._text=text; |
17 | this._animBy=null; |
17 | this._animBy=null; |
18 | this._inUse=0; |
18 | this._inUse=0; |
19 | this._dlyr=(dlyr||dynapi.document); |
19 | this._dlyr=(dlyr||dynapi.document); |
20 | 20 | ||
21 | this.setLocation(x,y); |
21 | this.setLocation(x,y); |
22 | this.animateBy(animBy); |
22 | this.animateBy(animBy); |
23 | this.visible=true; |
23 | this.visible=true; |
24 | 24 | ||
25 | var me=this; // use delegate "me" |
25 | var me=this; // use delegate "me" |
26 | var fn=function(){ |
26 | var fn=function(){ |
27 | me._created=true; |
27 | me._created=true; |
28 | me._split(); |
28 | me._split(); |
29 | } |
29 | } |
Line 43... | Line 43... | ||
43 | l.setVisible(false); |
43 | l.setVisible(false); |
44 | l.removeAllEventListeners(); |
44 | l.removeAllEventListeners(); |
45 | p[p.length]=l; |
45 | p[p.length]=l; |
46 | } |
46 | } |
47 | this._chars.length=0; |
47 | this._chars.length=0; |
48 | }; |
48 | }; |
49 | p._createCharLayer=function(t){ |
49 | p._createCharLayer=function(t){ |
50 | var l; |
50 | var l; |
51 | var p=this._lyrPool; |
51 | var p=this._lyrPool; |
52 | if (!p.length) l = this._dlyr.addChild(new DynLayer()); |
52 | if (!p.length) l = this._dlyr.addChild(new DynLayer()); |
53 | else { |
53 | else { |
Line 100... | Line 100... | ||
100 | }else { // By word or letter |
100 | }else { // By word or letter |
101 | if (this._animBy=='word') { |
101 | if (this._animBy=='word') { |
102 | t=t.replace(/\s/g,' ') |
102 | t=t.replace(/\s/g,' ') |
103 | ar=t.split(' '); |
103 | ar=t.split(' '); |
104 | } |
104 | } |
105 | else { |
105 | else { |
106 | ar=t.split(''); |
106 | ar=t.split(''); |
107 | } |
107 | } |
108 | for(i=0;i<ar.length;i++){ |
108 | for(i=0;i<ar.length;i++){ |
109 | if (ar[i]==' ') ar[i]=' '; |
109 | if (ar[i]==' ') ar[i]=' '; |
110 | lyr=c[i]=this._createCharLayer(ar[i]); |
110 | lyr=c[i]=this._createCharLayer(ar[i]); |
111 | lyr.setLocation(x,y); |
111 | lyr.setLocation(x,y); |
112 | x+=lyr.w; |
112 | x+=lyr.w; |
113 | } |
113 | } |
114 | } |
114 | } |
115 | if(lyr) lyr.addEventListener(TextAnimation._tiggerEvents); |
115 | if(lyr) lyr.addEventListener(TextAnimation._tiggerEvents); |
116 | }; |
116 | }; |
117 | p.animateBy=function(s,delay){ // all, letter, word |
117 | p.animateBy=function(s,delay){ // all, letter, word |
118 | this._animBy=s||this._animBy||'letter'; |
118 | this._animBy=s||this._animBy||'letter'; |
119 | this.setDelay(delay); |
119 | this.setDelay(delay); |
120 | this._split(); |
120 | this._split(); |
121 | }; |
121 | }; |
122 | p.getCharLayer = function(i){ |
122 | p.getCharLayer = function(i){ |
123 | if (i>=0 && i<this.chars.length) return this.chars[i]; |
123 | if (i>=0 && i<this.chars.length) return this.chars[i]; |
124 | }; |
124 | }; |
125 | p.setDelay = function(delay){ |
125 | p.setDelay = function(delay){ |
126 | this._ms=delay||this._ms||50; |
126 | this._ms=delay||this._ms||50; |
127 | }; |
127 | }; |
128 | p.setFont=function(size,family){ |
128 | p.setFont=function(size,family){ |
129 | 129 | ||
130 | }; |
130 | }; |
131 | p.setLocation=function(x,y){ |
131 | p.setLocation=function(x,y){ |
132 | x=x||0; y=y||0; |
132 | x=x||0; y=y||0; |
133 | var byX=x-this.x; |
133 | var byX=x-this.x; |
134 | var byY=y-this.y; |
134 | var byY=y-this.y; |
Line 140... | Line 140... | ||
140 | }; |
140 | }; |
141 | p.setText=function(t,animBy,delay){ |
141 | p.setText=function(t,animBy,delay){ |
142 | this._text=t||''; |
142 | this._text=t||''; |
143 | this.setDelay(delay); |
143 | this.setDelay(delay); |
144 | this.animateBy(animBy); |
144 | this.animateBy(animBy); |
145 | }; |
145 | }; |
146 | p.setVisible = function(b){ |
146 | p.setVisible = function(b){ |
147 | var c=this._chars; |
147 | var c=this._chars; |
148 | this.visible=b; |
148 | this.visible=b; |
149 | for (var i=0;i<c.length;i++) c[i].setVisible(b); |
149 | for (var i=0;i<c.length;i++) c[i].setVisible(b); |
150 | }; |
150 | }; |
151 | 151 | ||
152 | // Trigger Events |
152 | // Trigger Events |
153 | var fn = function(e){ |
153 | var fn = function(e){ |
154 | var o=e.getSource(); |
154 | var o=e.getSource(); |
155 | o._ta._inUse--; |
155 | o._ta._inUse--; |
156 | if(!o._ta._inUse) window.setTimeout(o._ta+'.invokeEvent("animfinish")',55); |
156 | if(!o._ta._inUse) window.setTimeout(o._ta+'.invokeEvent("animfinish")',55); |
Line 213... | Line 213... | ||
213 | l.setLocation(null,(this.y-h)+l._boncy+l.h); |
213 | l.setLocation(null,(this.y-h)+l._boncy+l.h); |
214 | } |
214 | } |
215 | 215 | ||
216 | if(l._boncmaxv!=0){ |
216 | if(l._boncmaxv!=0){ |
217 | this._exec(this+'._startBounce('+i+','+h+');'+ext,1); |
217 | this._exec(this+'._startBounce('+i+','+h+');'+ext,1); |
218 | } |
218 | } |
219 | else if(i==(c.length-1)) { |
219 | else if(i==(c.length-1)) { |
220 | this._exec(l+'.invokeEvent("pathfinish")',1); |
220 | this._exec(l+'.invokeEvent("pathfinish")',1); |
221 | } |
221 | } |
222 | }; |
222 | }; |
223 | // Fade In |
223 | // Fade In |
224 | p.fadeIn = function(inc,ms){ |
224 | p.fadeIn = function(inc,ms){ |
225 | var i,c=this._chars; |
225 | var i,c=this._chars; |
226 | this._exec(this+'.invokeEvent("animstart")',1); |
226 | this._exec(this+'.invokeEvent("animstart")',1); |
Line 244... | Line 244... | ||
244 | ((!this._inUse)? l+'.setVisible(true);':'') |
244 | ((!this._inUse)? l+'.setVisible(true);':'') |
245 | +l+'.slideTo('+l.x+','+l.y+','+inc+','+ms+');' |
245 | +l+'.slideTo('+l.x+','+l.y+','+inc+','+ms+');' |
246 | ,i); |
246 | ,i); |
247 | l.setLocation(x,y); |
247 | l.setLocation(x,y); |
248 | } |
248 | } |
249 | this._inUse++; |
249 | this._inUse++; |
250 | }; |
250 | }; |
251 | p.zoomText = function(from,to,inc,ms){ |
251 | p.zoomText = function(from,to,inc,ms){ |
252 | var i,l,c; |
252 | var i,l,c; |
253 | c=this._chars; |
253 | c=this._chars; |
254 | this._exec(this+'.invokeEvent("animstart")',1); |
254 | this._exec(this+'.invokeEvent("animstart")',1); |
Line 281... | Line 281... | ||
281 | if(i==0) l.setLocation(null,this.y-(l.h/2)); |
281 | if(i==0) l.setLocation(null,this.y-(l.h/2)); |
282 | else l.setLocation(this._chars[i-1].x+this._chars[i-1].w,this.y-(l.h/2)); |
282 | else l.setLocation(this._chars[i-1].x+this._chars[i-1].w,this.y-(l.h/2)); |
283 | if(from!=to) l._zTmr=window.setTimeout(this+'._startZoom('+i+')',l._zMs); |
283 | if(from!=to) l._zTmr=window.setTimeout(this+'._startZoom('+i+')',l._zMs); |
284 | else if(i==(this._chars.length-1)) { |
284 | else if(i==(this._chars.length-1)) { |
285 | this._exec(l+'.invokeEvent("pathfinish")',1); |
285 | this._exec(l+'.invokeEvent("pathfinish")',1); |
286 | } |
286 | } |
287 | }; |
287 | }; |
288 | - | ||
289 | 288 | ||
290 | // to-do: |
289 | // to-do: |
291 | p.wave = function(){}; |
290 | p.wave = function(){}; |
292 | p.nudge = function(){}; |
291 | p.nudge = function(){}; |
293 | p.quake = function(){}; |
292 | p.quake = function(){}; |