1BEGIN { $| = 1; print "1..12\n"; } 2END {print "not ok 1\n" unless $loaded;} 3 4use SWF::Element; 5use SWF::File; 6use SWF::Parser; 7 8$loaded=1; 9 10eval{ 11 $new = SWF::File->new('test.swf', Version=>6); 12}; 13print "not " if $@; 14print "ok 1\n"; 15 16eval { 17 $new->FrameSize(0, 0, 6400, 4800); 18 $new->FrameRate(20); 19 $new->compress; 20}; 21print "not " if $@; 22print "ok 2\n"; 23 24eval { 25 SWF::Element::Tag::SetBackgroundColor->new( 26 BackgroundColor => [ 27 Red => 255, 28 Green => 255, 29 Blue => 255, 30 ] 31)->pack($new); 32 33 SWF::Element::Tag::DefineShape3->new( 34 ShapeID => 1, 35 ShapeBounds => [ 36 Xmin => -1373, 37 Ymin => -1273, 38 Xmax => 1313, 39 Ymax => 1333, 40 ], 41 Shapes => [ 42 FillStyles => [ 43 [ 44 FillStyleType => 0, 45 Color => [ 46 Red => 255, 47 Green => 0, 48 Blue => 0, 49 Alpha => 255, 50 ] 51 ] 52 ], 53 ShapeRecords => [ 54 [ 55 MoveDeltaX => -30, 56 MoveDeltaY => -1240, 57 FillStyle0 => 1, 58 ], 59 [ 60 ControlDeltaX => 542, 61 ControlDeltaY => 0, 62 AnchorDeltaX => 384, 63 AnchorDeltaY => 372, 64 ], 65 [ 66 ControlDeltaX => 384, 67 ControlDeltaY => 372, 68 AnchorDeltaX => 0, 69 AnchorDeltaY => 526, 70 ], 71 [ 72 ControlDeltaX => 0, 73 ControlDeltaY => 526, 74 AnchorDeltaX => -384, 75 AnchorDeltaY => 372, 76 ], 77 [ 78 ControlDeltaX => -384, 79 ControlDeltaY => 372, 80 AnchorDeltaX => -542, 81 AnchorDeltaY => 0, 82 ], 83 [ 84 ControlDeltaX => -542, 85 ControlDeltaY => 0, 86 AnchorDeltaX => -384, 87 AnchorDeltaY => -372, 88 ], 89 [ 90 ControlDeltaX => -384, 91 ControlDeltaY => -372, 92 AnchorDeltaX => 0, 93 AnchorDeltaY => -526, 94 ], 95 [ 96 ControlDeltaX => 0, 97 ControlDeltaY => -526, 98 AnchorDeltaX => 384, 99 AnchorDeltaY => -372, 100 ], 101 [ 102 ControlDeltaX => 384, 103 ControlDeltaY => -372, 104 AnchorDeltaX => 542, 105 AnchorDeltaY => 0, 106 ], 107 ], 108 ], 109)->pack($new); 110 111 SWF::Element::Tag::FrameLabel->new( 112 Name => 'TEST SWF', 113)->pack($new); 114 115 SWF::Element::Tag::PlaceObject2->new( 116 Flags => 6, 117 Depth => 2, 118 CharacterID => 1, 119 Matrix => [ 120 ScaleX => 1, 121 ScaleY => 1, 122 RotateSkew0 => 0, 123 RotateSkew1 => 0, 124 TranslateX => 3200, 125 TranslateY => 2400, 126 ], 127)->pack($new); 128 SWF::Element::Tag::ShowFrame->new( 129)->pack($new); 130 SWF::Element::Tag::End->new( 131)->pack($new); 132 133 $new->close; 134}; 135 136print "not " if $@; 137print "ok 3\n"; 138 139eval { 140 $p = SWF::Parser->new( 'header-callback' =>\&header, 'tag-callback' =>\&tag ); 141}; 142print "not " if $@; 143print "ok 4\n"; 144 145$tagtest=6; 146$labelf=0; 147$p->parse_file('test.swf'); 148 149print "not " unless $labelf; 150print "ok $tagtest\n"; 151 152unlink 'test.swf'; 153 154sub header { 155 my ($self, $signature, $version, $length, $xmin, $ymin, $xmax, $ymax, $framerate, $framecount ) = @_; 156 157 print "not " if $signature ne 'CWS' or $version != 6 or $framerate != 20; 158 print "ok 5\n"; 159} 160 161sub tag { 162 my ($self, $tagno, $length, $datastream ) = @_; 163 164 my $element=SWF::Element::Tag->new(Tag=>$tagno, Length=>$length); 165 eval { 166 $element->unpack($datastream); 167 }; 168 print "not " if ($@); 169 print "ok $tagtest\n"; 170 $tagtest++; 171 $labelf=1 if (ref($element) =~/FrameLabel/ and $element->Name eq 'TEST SWF'); 172} 173