2 // Some tests for the Drawing API
4 // makeswf -o DrawingApi.swf DrawingApi.as
6 // firefox DrawingApi.swf
8 // gnash DrawingApi.swf
11 // Click the mouse button to turn the cursor shape into a mask and back.
12 // Press a number on the keyboard to switch between "pages" of the drawing.
13 // We currently have pages 1, 2, 3, 4.
14 // All pages are tested automatically.
16 // '-' and '+' decrement and increment _alpha
17 // 'h' toggles _visible
21 #include "../actionscript.all/check.as"
23 // Make Matrix visible for easier gradient tests.
24 ASSetPropFlags
(_global
, "flash", 0, 5248);
26 printBounds
= function(b
)
28 return ''+Math.round
(b
.xMin
*100)/100+','+Math.round
(b
.yMin
*100)/100+' '+Math.round
(b
.xMax
*100)/100+','+Math.round
(b
.yMax
*100)/100;
31 // Can draw both on a dynamically-created movie...
32 createEmptyMovieClip
("a", 10);
33 // ... or on a statically-created one
37 red
.valueOf
= function() { return 0xFF0000; };
40 thick
.valueOf
= function() { return 20; };
42 halftransparent
= new Object();
43 halftransparent
.valueOf
= function() { return 50; };
45 // Draw a circle with given center and radius
46 // Uses 8 curves to approximate the circle
47 drawCircle
= function (where
, x
, y
, rad
)
49 var ctl
= Math.sin
(24*Math.PI
/180)*rad
;
50 var cos
= Math.cos
(45*Math.PI
/180)*rad
;
51 var sin
= Math.sin
(45*Math.PI
/180)*rad
;
56 curveTo
(x
+ctl
, y
-rad
, x
+cos
, y
-sin
);
57 curveTo
(x
+rad
, y
-ctl
, x
+rad
, y
);
58 curveTo
(x
+rad
, y
+ctl
, x
+cos
, y
+sin
);
59 curveTo
(x
+ctl
, y
+rad
, x
, y
+rad
);
60 curveTo
(x
-ctl
, y
+rad
, x
-cos
, y
+sin
);
61 curveTo
(x
-rad
, y
+ctl
, x
-rad
, y
);
62 curveTo
(x
-rad
, y
-ctl
, x
-cos
, y
-sin
);
63 curveTo
(x
-ctl
, y
-rad
, x
, y
-rad
);
72 bnd
= printBounds
(a
.getBounds
());
73 if ( bnd
== "6710886.35,6710886.35 6710886.35,6710886.35" ) {
74 trace
("PASSED: getBounds() returns "+bnd
+" after clear");
76 trace
("FAILED: getBounds() returns "+bnd
+" after clear");
80 lineStyle
(thick
, red
, 100);
83 bnd
= printBounds
(a
.getBounds
());
84 check_equals
(bnd
, "6710886.35,6710886.35 6710886.35,6710886.35");
88 bnd
= printBounds
(a
.getBounds
());
89 check_equals
(bnd
, "80,80 220,220"); // line is 20 pixels thick..
91 // The hairlined horizontal black line
92 lineStyle
(0, 0x000000, 100);
95 bnd
= printBounds
(a
.getBounds
());
96 check_equals
(bnd
, "80,80 220,220"); // neither line style change nore moveTo change the bounds
100 bnd
= printBounds
(a
.getBounds
());
101 check_equals
(bnd
, "80,80 280,220"); // now hairlined line from 220,180 to 280,180 was added
105 lineStyle
(5, 0xFF00FF, halftransparent
);
107 bnd
= printBounds
(a
.getBounds
());
108 check_equals
(bnd
, "80,80 280,220"); // line style change and moveTo don't change anything
112 bnd
= printBounds
(a
.getBounds
());
113 check_equals
(bnd
, "80,80 280,255"); // line thinkness is now 5, so 250 gets to 255
116 lineStyle
(10, 0xFFFF00, 100);
119 bnd
= printBounds
(a
.getBounds
());
120 check_equals
(bnd
, "80,80 410,260"); // line thinkness of 10 adds to x (now 410) and to starting point y (was 250)
123 lineStyle
(8, 0x00FF00, 100);
124 curveTo
(400, 120, 300, 100);
125 check
( ! hitTest
(376, 180, true) );
126 check
( hitTest
(376, 139, true) );
128 bnd
= printBounds
(a
.getBounds
());
129 check_equals
(bnd
, "80,80 410,260"); // the curve is all inside the current bounds
135 // The black thick vertical line
139 bnd
= printBounds
(a
.getBounds
());
140 check_equals
(bnd
, "60,80 410,260"); // new thinkness of 20 moves our left margin
142 // The ugly blue-fill red-stroke thingy
144 lineStyle
(2, 0xFF0000);
145 beginFill
(0x0000FF, 100);
148 bnd
= printBounds
(a
.getBounds
());
149 check_equals
(bnd
, "48,80 410,260"); // we get left to 50-thickness(2) now
151 curveTo
(20, 200, 50, 250);
153 bnd
= printBounds
(a
.getBounds
());
154 check_equals
(bnd
, "18,80 410,260"); // we get left to 20-thickness(2) now
161 // The clockwise blue-stroke, cyan-fill square
163 lineStyle
(1, 0x00FF00);
164 beginFill
(0x00FFFF, 100);
171 bnd
= printBounds
(a
.getBounds
());
172 check_equals
(bnd
, "18,80 410,260"); // nothing new..
174 // The counter-clockwise cyan-stroke, green-fill (alpha 50) square
176 lineStyle
(1, 0x00FFFF);
177 beginFill
(0x00FF00, 50);
184 // The clockwise green-stroke, violet-fill square, with move after beginFill
185 lineStyle
(1, 0x00FF00);
186 beginFill
(0xFF00FF, 100);
195 lineStyle
(8, 0x000000);
196 beginFill
(0x00FF00, 100);
197 drawCircle
(a
, 330, 160, 35);
200 bnd
= printBounds
(a
.getBounds
());
201 check_equals
(bnd
, "18,80 410,260"); // nothing new..
203 createEmptyMovieClip
("zshape", 1);
206 // The Z-shaped 3 edges stroke
223 bnd
= printBounds
(zshape
.getBounds
());
224 check_equals
(bnd
, "219,141 277,169");
225 // "223,145 273,165" + 4 for thickness
226 check_equals
( typeof(zshape
.hitTest
), 'function' );
227 check
( zshape
.hitTest
(223, 145, true) ); // 0
228 check
( zshape
.hitTest
((223+10), (145+0), true) ); // 1
229 check
( zshape
.hitTest
((223+20), (145+5), true) ); // 2
230 check
( zshape
.hitTest
((223+25), (145+20), true) ); // 3
231 check
( zshape
.hitTest
(273, 165, true) ); // 4
233 // The ugly orange stroke / light brown fill
234 // expected to auto-close on endFill()
235 createEmptyMovieClip
("x", 20);
238 lineStyle
(6, 0xFF8800);
239 beginFill
(0x888800, 100);
241 //lineTo("string", NaN); // equivalent to 0, 0
243 //curveTo(100, "string", Object, 100); // equivalent to 100, 0, 0, 100
244 curveTo
(100, 0, 0 ,100);
245 //moteTo(undefined, 0); // equivalent to 0, 0
247 //lineTo(100, null); // equivalent to 100, 0
256 check
( x
.hitTest
(126, 168, true) );
257 check
( x
.hitTest
(112, 158, true) );
259 // COMPATIBLITY NOTE:
260 // flashplayer 10.0.12.10 for linux fails this, whereas 9.0.115.0 doesn't
261 check
( x
.hitTest
(122, 157, true) );
263 check
( ! x
.hitTest
(120, 155, true) );
264 check
( x
.hitTest
(120, 155, false) );
265 check
( ! x
.hitTest
(116, 177, true) );
266 check
( x
.hitTest
(116, 177, false) );
269 // Make the MovieClip "active" (grabbing mouse events)
270 // This allows testing of fill styles and "thick" lines
271 a
.onRollOver
= function() {};
274 a
.createEmptyMovieClip
("b", 2);
275 a
.onEnterFrame
= function()
281 ret
= delete this.onEnterFrame
;
283 trace
("PASSED: delete this.onEnterFrame returned "+ret
);
285 trace
("FAILED: delete this.onEnterFrame returned "+ret
);
290 // #40315: test that we don't crash without a line style.
291 this.b
.lineTo
(10, 20);
294 this.b
.lineStyle
(2, 0xFF0000);
295 this.b
.beginFill
(0xFFFF00, 100);
296 drawCircle
(this.b
, (50*frameno
), 280, 10);
301 //---------------------------------------------------------------------------
302 // Some invalid shapes, get there hitting the right-arrow
303 //---------------------------------------------------------------------------
305 createEmptyMovieClip
("inv", 100);
309 createEmptyMovieClip
("inv1", 1);
317 endFill
(); // should close to 10,10
319 inv1
._xscale
= inv1
._yscale
= 400;
320 inv1
.onRollOver
= function() {};
322 // Four intersecting edges (like in "four in a row")
323 createEmptyMovieClip
("inv2", 2);
326 lineStyle
(0, 0); // hairline
342 inv2
._xscale
= inv2
._yscale
= 400; inv2
._x
= 100;
343 inv2
.onRollOver
= function() {};
345 // Opposite el shapes
346 createEmptyMovieClip
("inv3", 3);
349 lineStyle
(0, 0); // hairline
361 inv3
._xscale
= inv3
._yscale
= 400; inv3
._y
= 100;
362 inv3
.onRollOver
= function() {};
364 check
( inv3
.hitTest
((8*4), 100 + (18*4), true) ); // Inside the left autofill
365 check
( !inv3
.hitTest
((4*4), 100 + (10*4), true) ); // Outside the left autofill (but in the boundaries)
366 check
( inv3
.hitTest
((4*4), 100 + (10*4), false) ); // Outside the left autofill (but in the boundaries)
368 check
( inv3
.hitTest
((20*4), 100 + (18*4), true) ); // Inside the right autofill
369 check
( !inv3
.hitTest
((24*4), 100 + (10*4), true) ); // Outside the right autofill (but in the boundaries)
370 check
( inv3
.hitTest
((24*4), 100 + (10*4), false) ); // Outside the right autofill (but in the boundaries)
372 // Nested squares (inner is an hole)
373 // Both squares are defined in counterclockwise order
374 createEmptyMovieClip
("inv4", 4);
377 lineStyle
(0, 0); // hairline
392 inv4
._xscale
= inv4
._yscale
= 400;
393 inv4
._y
= 100; inv4
._x
= 100;
394 inv4
.onRollOver
= function() {};
396 // check that a point inside the hole doesn't hit the shape
397 // (gnash fails due to bogus point_test, or missing normalization)
398 check
( ! inv4
.hitTest
(100 + (15*4), 100 + (15*4), true) );
400 // while a points on the border do hit it
401 check
( inv4
.hitTest
(100 + (11*4), 100 + (11*4), true) ); // Upper-Left
402 check
( inv4
.hitTest
(100 + (11*4), 100 + (14*4), true) ); // Center-Left
403 check
( inv4
.hitTest
(100 + (11*4), 100 + (19*4), true) ); // Lower-Left
404 check
( inv4
.hitTest
(100 + (14*4), 100 + (19*4), true) ); // Lower-Center
405 check
( inv4
.hitTest
(100 + (19*4), 100 + (19*4), true) ); // Lower-Right
406 check
( inv4
.hitTest
(100 + (19*4), 100 + (14*4), true) ); // Center-Right
407 check
( inv4
.hitTest
(100 + (19*4), 100 + (11*4), true) ); // Upper-Right
408 check
( inv4
.hitTest
(100 + (14*4), 100 + (11*4), true) ); // Upper-Center
410 // Nested squares (inner is an hole)
411 // Outer square counterclockwise order, inner in closwise order
412 // NOTE that there's no difference with inv4 in rendering and hit test
413 createEmptyMovieClip
("inv5", 5);
416 lineStyle
(0, 0); // hairline
431 inv5
._xscale
= inv5
._yscale
= 400;
432 inv5
._y
= 100; inv5
._x
= 150;
433 inv5
.onRollOver
= function() {};
435 // check that a point inside the hole doesn't hit the shape
436 // (gnash fails due to bogus point_test, or missing normalization)
437 check
( ! inv5
.hitTest
(150 + (15*4), 100 + (15*4), true) );
439 // while a points on the border do hit it
440 check
( inv5
.hitTest
(150 + (11*4), 100 + (11*4), true) ); // Upper-Left
441 check
( inv5
.hitTest
(150 + (11*4), 100 + (14*4), true) ); // Center-Left
442 check
( inv5
.hitTest
(150 + (11*4), 100 + (19*4), true) ); // Lower-Left
443 check
( inv5
.hitTest
(150 + (14*4), 100 + (19*4), true) ); // Lower-Center
444 check
( inv5
.hitTest
(150 + (19*4), 100 + (19*4), true) ); // Lower-Right
445 check
( inv5
.hitTest
(150 + (19*4), 100 + (14*4), true) ); // Center-Right
446 check
( inv5
.hitTest
(150 + (19*4), 100 + (11*4), true) ); // Upper-Right
447 check
( inv5
.hitTest
(150 + (14*4), 100 + (11*4), true) ); // Upper-Center
449 // Nested squares (this time we call beginFill again before the move)
450 // Outer square counterclockwise order, inner in clockwise order
451 // This time, the inner square will NOT be considered an hole !
452 createEmptyMovieClip
("inv6", 6);
455 lineStyle
(0, 0); // hairline
464 // this forces endFill call, which triggers finalization of previous path (I think)
473 inv6
._xscale
= inv6
._yscale
= 400;
474 inv6
._y
= 100; inv6
._x
= 200;
475 inv6
.onRollOver
= function() {};
477 // Point inside the inner square hits the shape !
478 check
( inv6
.hitTest
(200 + (15*4), 100 + (15*4), true) );
479 // As points on the outer borders
480 check
( inv6
.hitTest
(200 + (11*4), 100 + (11*4), true) ); // Upper-Left
481 check
( inv6
.hitTest
(200 + (11*4), 100 + (14*4), true) ); // Center-Left
482 check
( inv6
.hitTest
(200 + (11*4), 100 + (19*4), true) ); // Lower-Left
483 check
( inv6
.hitTest
(200 + (14*4), 100 + (19*4), true) ); // Lower-Center
484 check
( inv6
.hitTest
(200 + (19*4), 100 + (19*4), true) ); // Lower-Right
485 check
( inv6
.hitTest
(200 + (19*4), 100 + (14*4), true) ); // Center-Right
486 check
( inv6
.hitTest
(200 + (19*4), 100 + (11*4), true) ); // Upper-Right
487 check
( inv6
.hitTest
(200 + (14*4), 100 + (11*4), true) ); // Upper-Center
489 // Nested squares, calling beginFill again after the move)
490 // Outer square counterclockwise order, inner in clockwise order
491 createEmptyMovieClip
("inv7", 7);
494 lineStyle
(0, 0); // hairline
505 // this forces endFill call, which triggers finalization of previous path (I think)
513 inv7
._xscale
= inv7
._yscale
= 400;
514 inv7
._y
= 100; inv7
._x
= 250;
515 inv7
.onRollOver
= function() {};
517 // Point inside the inner square hits the shape !
518 check
( inv7
.hitTest
(250 + (15*4), 100 + (15*4), true) );
519 // As points on the outer borders
520 check
( inv7
.hitTest
(250 + (11*4), 100 + (11*4), true) ); // Upper-Left
521 check
( inv7
.hitTest
(250 + (11*4), 100 + (14*4), true) ); // Center-Left
522 check
( inv7
.hitTest
(250 + (11*4), 100 + (19*4), true) ); // Lower-Left
523 check
( inv7
.hitTest
(250 + (14*4), 100 + (19*4), true) ); // Lower-Center
524 check
( inv7
.hitTest
(250 + (19*4), 100 + (19*4), true) ); // Lower-Right
525 check
( inv7
.hitTest
(250 + (19*4), 100 + (14*4), true) ); // Center-Right
526 check
( inv7
.hitTest
(250 + (19*4), 100 + (11*4), true) ); // Upper-Right
527 check
( inv7
.hitTest
(250 + (14*4), 100 + (11*4), true) ); // Upper-Center
529 //------------------------------------------------
531 // Single path with complex crossing
534 // 10 5----4,0----------1
535 // |#####|###########|
536 // |#####|###########|
537 // 20 6-----+----7######|
546 //------------------------------------------------
547 createEmptyMovieClip
("inv8", 8);
563 // implicit close-up to 0 (aka 4, aka 20,10)
566 inv8
._xscale
= inv8
._yscale
= 200;
568 inv8
.onRollOver
= function() {};
570 check
( inv8
.hitTest
(200 + (15*2), 0 + (15*2), true) ); // Upper-Left
571 check
( inv8
.hitTest
(200 + (25*2), 0 + (15*2), true) ); // Upper-Center
572 check
( inv8
.hitTest
(200 + (35*2), 0 + (15*2), true) ); // Upper-Right
574 check
( !inv8
.hitTest
(200 + (15*2), 0 + (25*2), true) ); // Center-Left
575 check
( !inv8
.hitTest
(200 + (25*2), 0 + (25*2), true) ); // Center-Center
576 check
( inv8
.hitTest
(200 + (35*2), 0 + (25*2), true) ); // Center-Right
578 check
( !inv8
.hitTest
(200 + (15*2), 0 + (35*2), true) ); // Lower-Left
579 check
( inv8
.hitTest
(200 + (25*2), 0 + (35*2), true) ); // Lower-Center
580 check
( inv8
.hitTest
(200 + (35*2), 0 + (35*2), true) ); // Lower-Right
582 check
( !inv8
.hitTest
(200 + (20*2), 0 + (25*2), true) ); // On the 0-9 stroke, out of fill
588 createEmptyMovieClip
("line", 110);
600 // =======================
602 // =======================
605 lineStyle
(n
,0x0000ff,alpha
);
609 lineTo
((x
+xr
),(y
+yr
));
611 // In Gnash, next line forces a new path,
612 // and closeup of the former (shouldn't)
614 lineStyle
(n
,0x00ff00,alpha
);
621 // =======================
623 // =======================
628 lineStyle
(n
,1,alpha
);
633 lineStyle
(n
,0x0000ff,alpha
);
635 lineTo
((x
+xr
),(y
+yr
));
637 lineStyle
(n
,0x00ff00,alpha
);
644 // =======================
646 // =======================
650 createEmptyMovieClip
("d", 500);
653 lineStyle
(10, 10, 100);
656 lineTo
(x
+ xr
, y
+ yr
);
657 endFill
(); // does NOT force closeup
660 // =======================
662 // =======================
667 createEmptyMovieClip
("e", 501);
670 lineStyle
(10, 10, 100);
671 beginFill
(); // does NOT start a fill
674 lineTo
(x
+ xr
, y
+ yr
);
675 endFill
(); // does NOT force closeup
678 // The shape is not closed to form a triangle,
679 // so the only way to hit it is to hit the line.
680 check
(!e
.hitTest
(x
+ 30, y
+ 30, true));
682 // Top right 'corner'
683 check
(e
.hitTest
(x
, y
, true));
685 // =======================
687 // =======================
691 createEmptyMovieClip
("f", 502);
694 lineStyle
(10, 10, 100);
695 beginFill
(0); // does start a fill
698 lineTo
(x
+ xr
, y
+ yr
);
699 endFill
(); // DOES force closeup
702 // Somewhere within the closed triangle.
703 check
(f
.hitTest
(x
+ 30, y
+ 30, true));
705 // =======================
707 // =======================
711 createEmptyMovieClip
("g", 503);
714 lineStyle
(10, 0xFFFF00, 100);
715 beginFill
(0x00ff00); // does start a fill
718 lineTo
(x
+ xr
, y
+ yr
);
719 beginFill
(0x0000ff); // closes previous fill, opens a new one
721 lineTo
(x
+ xr
, y
+ yr
);
722 endFill
(); // DOES force closeup
726 check
(g
.hitTest
(x
+ 20, y
+ 80, true));
729 // COMPATIBLITY NOTE:
730 // 9,0,115,0 for linux sometimes finds the point to hit
731 // the shape and sometimes it doesn't.
732 // 10,0,12,10 never succeeds the hit test.
734 // The point is clearly within a fill so we'll take an hit test
735 // success as expected.
737 check
(g
.hitTest
(x
+ 80, y
+ 20, true));
741 line
.onRollOver
= function() {};
743 // Check the the top right diagonal half of Shape 2.
744 xcheck
(line
.hitTest
(270, 40, true));
746 // Check the bottom left diagonal half of Shape 2.
747 check
(line
.hitTest
(230, 80, true));
750 // Page 4 ( page[3] )
752 draw100x100Box
= function(x
, y
, mc
) {
757 lineTo
(x
+ s
, y
+ s
);
765 createEmptyMovieClip
("grad", 150);
768 // The beginGradientFill function works with fake Matrices, but there is no
769 // point making more work for ourselves as that testing is already done for
771 // Only the "box" matrixType gets special handling.
782 colors
= [0x0000ff, 0xffffff];
785 matrix
= new flash
.geom
.Matrix();
786 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
787 draw100x100Box
(x
, y
, grad
);
791 colors
= [0x0000ff, 0xffffff];
794 matrix
.createGradientBox
(90, 90, 0, x
, y
);
795 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
796 draw100x100Box
(x
, y
, grad
);
800 colors
= [0x0000ff, 0xffffff, 0xff00ff];
801 alphas
= [100, 100, 100];
802 ratios
= [0, 0xff / 2, 0xff];
803 matrix
.createGradientBox
(90, 90, Math.PI
/ 4, x
, y
);
804 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
805 draw100x100Box
(x
, y
, grad
);
809 colors
= [0x0000ff, 0xffffff, 0xff00ff];
810 alphas
= [100, 100, 100];
811 ratios
= [0, 0xff / 2, 0xff];
812 matrix
.createGradientBox
(180, 180, Math.PI
/ 4, x
, y
);
813 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
814 draw100x100Box
(x
, y
, grad
);
818 colors
= [0x0000ff, 0xffffff, 0x00ff00];
819 alphas
= [100, 100, 100];
820 ratios
= [0, 0xff / 2, 0xff];
821 matrix
.createGradientBox
(180, 180, Math.PI
/ 4 * 3, x
- 90, y
- 90);
822 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
823 draw100x100Box
(x
, y
, grad
);
827 colors
= [0x0000ff, 0xffffff, 0x00ff00, 0xff00ff, 0x00ffff, 0xffff00 ];
828 alphas
= [100, 100, 100, 50, 25, 100];
829 ratios
= [0, 0xff / 5, 0xff / 5 * 2, 0xff / 5 * 3, 0xff / 5 * 4, 0xff];
830 matrix
.createGradientBox
(90, 90, Math.PI
/ 2, x
, y
);
831 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
832 draw100x100Box
(x
, y
, grad
);
841 colors
= [0x0000ff, 0xffffff];
844 matrix
= new flash
.geom
.Matrix();
845 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
846 draw100x100Box
(x
, y
, grad
);
850 colors
= [0x0000ff, 0xffffff];
853 matrix
.createGradientBox
(90, 90, 0, x
, y
);
854 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
855 draw100x100Box
(x
, y
, grad
);
859 colors
= [0x0000ff, 0xffffff, 0xff00ff];
860 alphas
= [100, 100, 100];
861 ratios
= [0, 0xff / 2, 0xff];
862 matrix
.createGradientBox
(90, 90, Math.PI
/ 4, x
, y
);
863 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
864 draw100x100Box
(x
, y
, grad
);
868 colors
= [0x0000ff, 0xffffff, 0xff00ff];
869 alphas
= [100, 100, 100];
870 ratios
= [0, 0xff / 2, 0xff];
871 matrix
.createGradientBox
(180, 180, Math.PI
/ 4, x
, y
);
872 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
873 draw100x100Box
(x
, y
, grad
);
877 colors
= [0x0000ff, 0xffffff, 0x00ff00];
878 alphas
= [100, 100, 100];
879 ratios
= [0, 0xff / 2, 0xff];
880 matrix
.createGradientBox
(180, 180, Math.PI
/ 4 * 3, x
- 90, y
- 90);
881 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
882 draw100x100Box
(x
, y
, grad
);
886 colors
= [0x0000ff, 0xffffff, 0x00ff00, 0xff00ff, 0x00ffff, 0xffff00 ];
887 alphas
= [100, 100, 100, 50, 25, 100];
888 ratios
= [0, 0xff / 5, 0xff / 5 * 2, 0xff / 5 * 3, 0xff / 5 * 4, 0xff];
889 matrix
.createGradientBox
(90, 90, Math.PI
/ 2, x
, y
);
890 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
891 draw100x100Box
(x
, y
, grad
);
898 // Check that ratios are adjusted if they do not get successively larger.
900 colors
= [0x0000ff, 0xffffff, 0x00ff00];
901 alphas
= [100, 100, 100];
902 ratios
= [0, 0x10, 0x05];
903 matrix
.createGradientBox
(90, 90, 0, x
, y
);
904 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
905 draw100x100Box
(x
, y
, grad
);
911 // Test a linear gradient with one stop
916 matrix
.createGradientBox
(90, 90, 0, x
, y
);
917 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
918 draw100x100Box
(x
, y
, grad
);
924 // Test a linear gradient with one stop
929 matrix
.createGradientBox
(90, 90, 0, x
, y
);
930 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
931 draw100x100Box
(x
, y
, grad
);
936 // Bad fill style results in no fill.
938 colors
= [0x0000ff, 0xffffff, 0x00ff00];
939 alphas
= [100, 100, 100];
940 ratios
= [0, 0x10, 0x05];
941 matrix
.createGradientBox
(90, 90, 0, x
, y
);
942 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
);
943 draw100x100Box
(x
, y
, grad
);
948 // Extra arguments result in no fill for SWF6
950 colors
= [0x0000ff, 0xffffff, 0x00ff00];
951 alphas
= [100, 100, 100];
952 ratios
= [0, 0x10, 0x05];
953 matrix
.createGradientBox
(90, 90, 0, x
, y
);
954 beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
, "pad");
955 draw100x100Box
(x
, y
, grad
);
962 // 4 arguments result in no fill for SWF6
964 colors
= [0x0000ff, 0xffffff, 0x00ff00];
965 alphas
= [100, 100, 100];
966 ratios
= [0, 0x10, 0x05];
967 matrix
.createGradientBox
(90, 90, 0, x
, y
);
968 beginGradientFill
(fillType
, colors
, alphas
, ratios
);
969 draw100x100Box
(x
, y
, grad
);
974 grad
.onRollOver
= function() {};
976 //---------------------------------------------------------------------------
978 //---------------------------------------------------------------------------
980 createEmptyMovieClip
("hitdetector", 3);
981 hitdetector
.createEmptyMovieClip
("shapeshape", 1);
982 with(hitdetector
.shapeshape
)
984 lineStyle
(2, 0x000000);
985 beginFill
(0xFFFF00, 100);
986 drawCircle
(hitdetector
.shapeshape
, 0, 0, 20);
990 hitdetector
.createEmptyMovieClip
("bboxpoint", 2);
991 with(hitdetector
.bboxpoint
)
993 lineStyle
(2, 0x000000);
994 beginFill
(0xFFFF00, 100);
995 drawCircle
(hitdetector
.bboxpoint
, 0, 0, 20);
1000 hitdetector
.createEmptyMovieClip
("shapepoint", 3);
1001 with(hitdetector
.shapepoint
)
1003 lineStyle
(2, 0x000000);
1004 beginFill
(0xFFFF00, 100);
1005 drawCircle
(hitdetector
.shapepoint
, 0, 0, 20);
1010 hitdetector
._y
= 350;
1013 createEmptyMovieClip
("cursor", 12);
1016 lineStyle
(2, 0x000000);
1017 beginFill
(0xFF0000, 100);
1018 drawCircle
(_root
.cursor
, 0, 0, 10);
1020 onEnterFrame
= function()
1022 hd
= _root
.hitdetector
;
1024 // don't move the controls for now...
1028 if ( typeof(xshift
) == 'undefined' )
1032 else if ( xshift
> 0 && _x
>= 300 )
1036 else if ( xshift
< 0 && _x
== 0 )
1049 var ch
= _root
.page
[_root
.visibleIndex
];
1051 // Bounding box check
1052 if ( hitTest
(ch
) ) {
1053 hd
.shapeshape
._xscale
=150;
1054 hd
.shapeshape
._yscale
=150;
1056 hd
.shapeshape
._xscale
=100;
1057 hd
.shapeshape
._yscale
=100;
1060 // Bounding box check with circle center
1061 if ( ch
.hitTest
(_x
, _y
) ) {
1062 hd
.bboxpoint
._xscale
=150;
1063 hd
.bboxpoint
._yscale
=150;
1065 hd
.bboxpoint
._xscale
=100;
1066 hd
.bboxpoint
._yscale
=100;
1069 // Shape check with circle center
1070 if ( ch
.hitTest
(_x
, _y
, true) ) {
1071 hd
.shapepoint
._xscale
=150;
1072 hd
.shapepoint
._yscale
=150;
1074 hd
.shapepoint
._xscale
=100;
1075 hd
.shapepoint
._yscale
=100;
1082 onMouseDown
= function()
1084 var ch
= _root
.page
[_root
.visibleIndex
];
1088 ch
.setMask
(); // no effect !
1089 ch
.setMask
(true); // no effect !
1090 trace
("Disabling cursor mask");
1091 ch
.setMask
(undefined); // works
1092 //a.setMask(null); // also work
1096 trace
("Enabling cursor mask");
1111 onKeyDown
= function()
1113 var ascii
= Key
.getAscii
();
1114 if ( ascii
>= 48 && ascii
<= 57 ) // 0..9 - activate corresponding drawing
1116 with (page
[visibleIndex
])
1122 visibleIndex
= parseInt
(ascii
)-49;
1123 trace
("Key "+visibleIndex
+" hit");
1125 with (page
[visibleIndex
])
1130 else if ( ascii
== 104 ) // 'h' - toggle visibility
1132 page
[visibleIndex
]._visible
= ! page
[visibleIndex
]._visible
;
1134 else if ( ascii
== 45 ) // '-' - decrease alpha
1136 var newAlpha
= page
[visibleIndex
]._alpha
- 25;
1137 if ( newAlpha
< 0 ) newAlpha
= 0;
1138 page
[visibleIndex
]._alpha
= newAlpha
;
1140 else if ( ascii
== 43 ) // '+' - increase alpha
1142 var newAlpha
= page
[visibleIndex
]._alpha
+ 25;
1143 if ( newAlpha
> 100 ) newAlpha
= 100;
1144 page
[visibleIndex
]._alpha
= newAlpha
;
1146 else if ( ascii
== 100 ) // 'd' - start/stop dragging something :)
1148 if ( ! hitdetector
.dragging
) {
1149 hitdetector
.dragging
= true;
1150 hitdetector
.startDrag
();
1151 // hitdetector.startDrag(true); // lock centered
1152 //hitdetector.startDrag(true, 100, 100, 200, 200); // lock centered, box-constrained
1154 hitdetector
.dragging
= flase
;
1155 hitdetector
.stopDrag
();
1160 Key
.addListener
(this);