swfc based viewer for pdf2swf swfs
[swftools.git] / swfs / rfxview.sc
1 .flash filename=rfxview.swf fps=30 bbox=600x800 version=8 compress background=#CCCCCC export=0
2
3 .define width 600
4 .define height 800
5
6 #======================================== buttons ===========================================================
7
8 .gradient grad1 radial x=4 y=4 r=28:
9  0% white
10  50% #666666
11  100% #202020
12 .end
13 .gradient grad2 linear width=8 height=6 rotate=120:
14  0% white
15  70% #666666
16  100% #202020  
17 .end
18 .gradient grad4 linear width=8 height=6 rotate=120:
19  0% white
20  70% #999999
21  100% #404040
22 .end
23
24 .gradient grad2l linear width=8 height=6 rotate=120:
25  0% #e0e0e0
26  100% #000000  
27 .end
28 .gradient grad4l linear width=8 height=6 rotate=120:
29  0% #ffffff
30  100% #404040
31 .end
32
33 .gradient grad3 radial x=4 y=4 r=28:
34  0% white
35  70% #999999
36  100% #404040
37 .end
38
39 .gradient grad7 linear rotate=180:
40  0% #777777
41  100% #666666
42 .end
43
44 .gradient grad72 linear rotate=45:
45  0% #999999
46  100% #666666
47 .end
48
49 .outline arrowoutline:
50     moveTo -8,-8
51     lineTo -8, 8
52     lineTo  8, 0
53     lineTo -8,-8
54 .end
55
56 .outline larrowoutline:
57     moveTo 8,-8
58     lineTo 8, 8
59     lineTo -8, 0
60     lineTo 8,-8
61 .end
62
63 .font arialbold filename="../viewer/ArialBold.ttf" glyphs="1:"
64 .font arial filename="../viewer/Arial.ttf" glyphs="0123456789 /:"
65
66 .textshape oneoneoutline text="1:1" font=arialbold size=14pt
67
68 .outline plusoutline:
69     moveTo  2,-8
70     lineTo -2,-8
71     lineTo -2,-2
72     lineTo -8,-2
73     lineTo -8,2
74     lineTo -2,2
75     lineTo -2,8
76     lineTo  2,8
77     lineTo  2,2
78     lineTo  8,2
79     lineTo  8,-2
80     lineTo  2,-2
81     lineTo  2,-8
82 .end
83
84 .outline minusoutline:
85     moveTo -7,2
86     lineTo -7,-2
87     lineTo  7,-2
88     lineTo  7,2
89     lineTo -7,2
90 .end
91
92 .circle shadcircle line=0 fill=#00000033 r=11.5
93
94 .circle outcircle line=2 color=#00000060 fill=grad1 r=11
95 .circle outcircle_over line=2 color=#00000060 fill=grad3 r=11
96
97 .filled incircle outline=arrowoutline fill=grad2 line=1 color=#00000060
98 .filled incircle_over outline=arrowoutline fill=grad4 line=1 color=#00000060
99 .filled lincircle outline=larrowoutline fill=grad2l line=1 color=#00000060
100 .filled lincircle_over outline=larrowoutline fill=grad4l line=1 color=#00000060
101 .filled pincircle outline=plusoutline fill=grad2l line=1 color=#00000060
102 .filled pincircle_over outline=plusoutline fill=grad4l line=1 color=#00000060
103 .filled mincircle outline=minusoutline fill=grad2l line=1 color=#00000060
104 .filled mincircle_over outline=minusoutline fill=grad4l line=1 color=#00000060
105 .filled oincircle outline=oneoneoutline fill=grad2l line=1.2 color=#00000060
106 .filled oincircle_over outline=oneoneoutline fill=grad4l line=1.2 color=#00000060
107
108 .sprite plusface
109  .put shadcircle 11 13 pin=center .put outcircle 11 11 pin=center .put pincircle 11 11 pin=center scale=90%
110 .end
111 .sprite plusfaceover 
112  .put shadcircle 11 13 pin=center .put outcircle_over 11 11 pin=center .put pincircle_over 11 11 pin=center scale=90%
113 .end
114 .sprite plusfacedown 
115  .put shadcircle 11 13 pin=center scale=90% .put outcircle_over 11 11 pin=center scale=90% .put pincircle_over 11 11 pin=center scale=79%
116 .end
117
118 .sprite minusface
119  .put shadcircle 11 13 pin=center .put outcircle 11 11 pin=center .put mincircle 11 11 pin=center scale=90% luminance=60%
120 .end
121 .sprite minusfaceover 
122  .put shadcircle 11 13 pin=center .put outcircle_over 11 11 pin=center .put mincircle_over 11 11 pin=center scale=90%
123 .end
124 .sprite minusfacedown 
125  .put shadcircle 11 13 pin=center scale=90% .put outcircle_over 11 11 pin=center scale=90% .put mincircle_over 11 11 pin=center scale=79%
126 .end
127
128 .sprite rbface
129  .put shadcircle 11 13 pin=center .put outcircle 11 11 pin=center .put incircle 13 11 pin=center scale=90%
130 .end
131 .sprite rbfaceover 
132  .put shadcircle 11 13 pin=center .put outcircle_over 11 11 pin=center .put incircle_over 13 11 pin=center scale=90%
133 .end
134 .sprite rbfacedown 
135  .put shadcircle 11 13 pin=center scale=90% .put outcircle_over 11 11 pin=center scale=90% .put incircle_over 13 11 pin=center scale=79%
136 .end
137
138 .sprite lbface
139  .put shadcircle 11 13 pin=center .put outcircle 11 11 pin=center .put lincircle 9 11 pin=center scale=90%
140 .end
141 .sprite lbfaceover 
142  .put shadcircle 11 13 pin=center .put outcircle_over 11 11 pin=center .put lincircle_over 9 11 pin=center scale=90%
143 .end
144 .sprite lbfacedown 
145  .put shadcircle 11 13 pin=center scale=90% .put outcircle_over 11 11 pin=center scale=90% .put lincircle_over 9 11 pin=center scale=79%
146 .end
147
148 .sprite obface
149  .put shadcircle 11 13 pin=center .put outcircle 11 11 pin=center .put oincircle 9 11 pin=center scale=90% luminance=50%
150 .end
151 .sprite obfaceover 
152  .put shadcircle 11 13 pin=center .put outcircle_over 11 11 pin=center .put oincircle_over 9 11 pin=center scale=90%
153 .end
154 .sprite obfacedown 
155  .put shadcircle 11 13 pin=center scale=90% .put outcircle_over 11 11 pin=center scale=90% .put oincircle_over 9 11 pin=center scale=79%
156 .end
157
158 .button rightbutton
159   .show rbface as=idle
160   .show outcircle as=area
161   .show rbfacedown as=pressed
162   .show rbfaceover as=hover
163 .end
164
165 .button leftbutton
166   .show lbface as=idle
167   .show outcircle as=area
168   .show lbfacedown as=pressed
169   .show lbfaceover as=hover
170 .end
171
172 .button plusbutton
173   .show plusface as=idle
174   .show outcircle as=area
175   .show plusfacedown as=pressed
176   .show plusfaceover as=hover
177 .end
178
179 .button minusbutton
180   .show minusface as=idle
181   .show outcircle as=area
182   .show minusfacedown as=pressed
183   .show minusfaceover as=hover
184 .end
185
186 .button oneonebutton
187   .show obface as=idle
188   .show outcircle as=area
189   .show obfacedown as=pressed
190   .show obfaceover as=hover
191 .end
192
193 #======================================== frame ===========================================================
194   
195 .frame 1
196
197 .put p1=plusbutton x=width-25-20 y=20 pin=center
198 .put m1=minusbutton x=width-50-20 y=20 pin=center
199 .put l1=leftbutton x=width/2-100 y=20 pin=center
200 .put r1=rightbutton x=width/2+100 y=20 pin=center
201
202 .put o1=oneonebutton x=width-75-20 y=20 pin=center
203
204 .sprite background
205 .end
206 .put background
207
208 .sprite vscrollbar
209     .box vscroll2_shadow line=0 fill=#00000033 width=14 height=100
210     .sprite vshadow
211     .put vscroll2_shadow x=0 y=0 luminance=1.8
212     .end
213     .put vshadow
214
215     .box vscroll2 width=14 height=100 line=1 color=#00000060 fill=grad7
216     .sprite vbox
217     .put vscroll2 x=0 y=0 luminance=1.5
218     .end
219     .put vbox
220
221     .box tick line=1 color=black width=8 height=0
222
223     .sprite t1 .put tt1=tick y=0 x=3 .end .put t1
224     .sprite t2 .put tt2=tick y=0 x=3 .end .put t2 y=50
225     .sprite t3 .put tt3=tick y=0 x=3 .end .put t3
226     
227     .button vscrollbutton
228         .show vscroll2 as=area
229         .on_press inside:
230             startDrag(false, _parent.fullwidth-22, 40, 
231                              _parent.fullwidth-22, 40+_parent.scrollbaryrange);
232             _parent.Dragging = "v";
233         .end
234         .on_release:
235             stopDrag();
236             _parent.refreshDrag();
237             _parent.Dragging = "";
238         .end
239     .end
240     .put vscrollbutton
241 .end
242
243 .sprite hscrollbar
244     .box hscroll2_shadow width=100 line=0 fill=#00000033 height=14
245     .sprite hshadow
246         .put hscroll2_shadow x=0 y=0 luminance=1.5
247     .end
248     .put hshadow
249
250     .box hscroll2 width=100 height=14 line=1 color=#00000060 fill=grad72
251     .sprite hbox
252     .put hscroll2 x=0 y=0 luminance=1.5
253     .end 
254     .put hbox
255
256     .box htick line=1 color=black width=0 height=8
257
258     .sprite th1 .put tht1=htick x=0 y=3 .end .put th1
259     .sprite th2 .put tht2=htick x=0 y=3 .end .put th2 x=50
260     .sprite th3 .put tht3=htick x=0 y=3 .end .put th3
261
262     .button hscrollbutton
263         .show hscroll2 as=area
264         .on_press inside:
265             startDrag(false, 10                        , _parent.fullheight-22, 
266                              10+_parent.scrollbarxrange, _parent.fullheight-22);
267             _parent.Dragging = "h";
268         .end
269         .on_release:
270             stopDrag();
271             _parent.refreshDrag();
272             _parent.Dragging = "";
273         .end
274     .end
275     .put hscrollbutton
276 .end
277
278 .put hscrollbar y=height-22 x=10
279 .put vscrollbar x=width-22 y=40
280
281 .edittext et width=110 height=20 font=arial size=18pt color=black noselect align=center
282
283 .font dbgarial filename="../doc/Courier.ttf"
284 #.edittext debugtxt width=width height=20 font=dbgarial size=18pt color=#004000 noselect
285 #.put debugtxt y=20
286
287 .put et x=width/2-30 y=8
288
289 #.swf swf filename=paper5.swf
290 .sprite swf
291 .end
292
293 .box f width=100 height=100 line=0 fill=black
294
295 .button areabutton
296     .show f as=area
297     .on_press inside:
298         swf.startDrag(false, left-scrollxrange, top-scrollyrange, left,top);
299         Dragging = "xy";
300     .end
301     .on_release:
302         swf.stopDrag();
303         Dragging = "";
304     .end
305 .end
306 .put areabutton x=10 y=40
307
308 .sprite cf
309     .put f
310 .end
311 .put cliparea=cf x=10 y=40
312 .put swf x=10 y=40
313
314 .action:
315
316     swfwidth = swf._width;
317     swfheight = swf._height;
318
319     Dragging = "";
320     
321     Stage.scaleMode="noScale";
322     Stage.align ="LT";
323     
324     //Stage.showMenu = false;
325
326     fullwidth = Stage.width;
327     fullheight = Stage.height;
328     contentwidth = fullwidth - 40;
329     contentheight = fullheight - 70;
330
331     // move all objects to their proper positions
332     vscrollbar._x = fullwidth-22;
333     hscrollbar._y = fullheight-22;
334     p1._x = fullwidth-25-20 - p1._width/2;
335     o1._x = fullwidth-50-20 - o1._width/2;
336     m1._x = fullwidth-75-20 - m1._width/2;
337
338     l1._x = fullwidth/2-100 - l1._width/2;
339     r1._x = fullwidth/2+100 - r1._width/2;
340
341     et._x = fullwidth/2 - et._width/2;
342
343     //.box f width=width-40 height=height-40-30 line=0 fill=black
344     //.box vscroll1 width=10 height=height-40-30 line=1 color=#00000060 fill=grad7
345     //.box hscroll1 height=10 width=width-40 line=1 color=#00000060 fill=grad72
346     //.put vscroll1 x=width-20 y=40
347     //.put hscroll1 x=10 y=height-20
348         
349     // horizontal scrollbar
350     background.lineStyle(1, 0, 0x60);
351     background.moveTo(10         ,fullheight-20);
352     background.lineTo(10         ,fullheight-10);
353     background.lineTo(10+fullwidth-40,fullheight-10);
354     background.lineTo(10+fullwidth-40,fullheight-20);
355     background.lineTo(10         ,fullheight-20);
356     
357     // vertical scrollbar
358     background.moveTo(fullwidth-20 ,40);
359     background.lineTo(fullwidth-20 ,fullheight-30);
360     background.lineTo(fullwidth-10 ,fullheight-30);
361     background.lineTo(fullwidth-10 ,40);
362     background.lineTo(fullwidth-20 ,40);
363
364     // content area
365     background.lineStyle(1, 0);
366     background.startFill(0x000000);
367     background.moveTo(9, 39);
368     background.lineTo(fullwidth-30+1, 39);
369     background.lineTo(fullwidth-30+1, fullheight-29);
370     background.lineTo(9, fullheight-29);
371     background.lineTo(9, 39);
372     background.endFill();
373     
374     areabutton._xscale = contentwidth;
375     areabutton._yscale = contentheight;
376     cliparea._xscale = contentwidth;
377     cliparea._yscale = contentheight;
378     swf.setMask(cliparea);
379     
380
381     lastzoom = 1;
382
383     zoom = 1;
384         
385     //debugtxt.text = Stage.width+ " x " + Stage.height;
386
387     setPageNr = function() {
388         et.text = "  "+pagenr+" / "+swf._totalframes;
389         swf.gotoAndStop(pagenr);
390     };
391    
392     setNoScrollZoomLevel = function() {
393         // determine initial zoom level
394         xscale = contentwidth / swfwidth;
395         yscale = contentheight / swfheight;
396         if(xscale < yscale) {
397             zoom = xscale;
398             setZoomLevel();
399         } else {
400             zoom = yscale;
401             setZoomLevel();
402         }
403     };
404     
405     set11ZoomLevel = function() {
406         zoom = 1.0;
407         setZoomLevel();
408     };
409
410     swfpos2scrollbars = function() {
411         if(scrollxrange) {
412             hscrollbar._x = 10 + (left-swf._x)*scrollbarxrange/scrollxrange;
413         } else {
414             hscrollbar._x = 10;
415         }
416         if(scrollyrange) {
417             vscrollbar._y = 40 + (top-swf._y)*scrollbaryrange/scrollyrange;
418         } else {
419             vscrollbar._y = 40;
420         }
421     };
422     setZoomLevel = function() {
423
424         width = contentwidth;
425         height = contentheight;
426         left = 10;
427         top = 40;
428
429         if(swfwidth * zoom < contentwidth) {
430             width = swfwidth*zoom;
431             left = 10+(contentwidth-width)/2;
432         }
433         if(swfheight * zoom < contentheight) {
434             height = swfheight*zoom;
435             top = 40+(contentheight-height)/2;
436         }
437             
438         scrollxrange = swfwidth*zoom-width;
439         scrollyrange = swfheight*zoom-height;
440    
441         hscrollbar._xscale = (contentwidth*width) / (swfwidth*zoom);
442         vscrollbar._yscale = (contentheight*height) / (swfheight*zoom);
443         scrollbarxrange = contentwidth - hscrollbar._xscale;
444         scrollbaryrange = contentheight - vscrollbar._yscale;
445         if(scrollbarxrange<0) {
446             scrollbarxrange = 0;
447         }
448         if(scrollbaryrange<0) {
449             scrollbaryrange = 0;
450         }
451
452         swf._xscale = zoom*100;
453         swf._yscale = zoom*100;
454    
455         focusx = contentwidth/2 - (swf._x-10);
456         focusy = contentheight/2 - (swf._y-40);
457
458         swf._x = left - focusx * zoom / lastzoom + width/2;
459         swf._y = top - focusy * zoom / lastzoom + height/2;
460
461         if(swf._x > left) {
462             swf._x = left;
463         } else if(swf._x < left-scrollxrange) {
464             swf._x = left-scrollxrange;
465         } 
466         if(swf._y > top) {
467             swf._y = top;
468         } else if(swf._y < top-scrollyrange) {
469             swf._y = top-scrollyrange;
470         }
471
472         swfpos2scrollbars();
473
474         if(scrollxrange) {
475             hscrollbar._visible = 1;
476         } else {
477             //hscrollbar._visible = 0;
478         }
479         if(scrollyrange) {
480             vscrollbar._visible = 1;
481         } else {
482             //vscrollbar._visible = 0;
483         }
484
485         lastzoom = zoom;
486
487         // update the ruler decorations
488
489         vscrollbar.t1._y = vscrollbar.t2._y - 600.0/vscrollbar._yscale;
490         vscrollbar.t3._y = vscrollbar.t2._y + 600.0/vscrollbar._yscale;
491         hscrollbar.th1._x = hscrollbar.th2._x - 600.0/hscrollbar._xscale;
492         hscrollbar.th3._x = hscrollbar.th2._x + 700.0/hscrollbar._xscale;
493
494         vscrollbar.vshadow._x = vscrollbar.vbox._x + 500/vscrollbar._xscale;
495         vscrollbar.vshadow._y = vscrollbar.vbox._y + 500/vscrollbar._yscale;
496         
497         hscrollbar.hshadow._x = hscrollbar.hbox._x + 500/hscrollbar._xscale;
498         hscrollbar.hshadow._y = hscrollbar.hbox._y + 500/hscrollbar._yscale;
499     };
500
501     pagenr = 1;
502     setPageNr();
503     setNoScrollZoomLevel();
504     //set11ZoomLevel();
505         
506     l1.onRelease = function(){ 
507         if(pagenr > 1) {
508             pagenr = pagenr - 1;
509             setPageNr();
510         }
511     };
512     r1.onRelease = function(){ 
513         if(pagenr < swf._totalframes) {
514             pagenr = pagenr + 1;
515             setPageNr();
516         }
517     };
518     p1.onRelease = function(){ 
519         if(zoom < 4) {
520             zoom = zoom + 1;
521             setZoomLevel();
522         }
523     };
524     m1.onRelease = function(){ 
525         if(zoom > 1) {
526             zoom = zoom - 1;
527             if(zoom < 1)
528                 zoom = 1;
529             setZoomLevel();
530         }
531     };
532     o1.onRelease = function(){ 
533         setNoScrollZoomLevel();
534     };
535     refreshDrag = function(){
536         if(Dragging == "h") {
537             swf._x = left + (10-hscrollbar._x)*scrollxrange/scrollbarxrange;
538         } else if(Dragging == "v") {
539             swf._y = top + (40-vscrollbar._y)*scrollyrange/scrollbaryrange;
540         } else if(Dragging == "xy") {
541             swfpos2scrollbars();
542         }
543     };
544     dragrefresh = setInterval(refreshDrag, 20);
545 .end
546
547 .end