Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have come across a perl script that appears to be building a shockwave flash object, probably via the SWF-File-0.42 library. However, I cannot get the script to execute correctly; with some modifications I can get the PNG files loaded into zlibdata and displayed/animated, but the pictures overlap when png should be see-through. Anyone understand how to get a swf graphic object built ? (Long) code listing follows:
PngFileTable = { png => shinki_menu_0_?.png, png => shinki_menu_1_?.png, ) Header: SIGNATURE = CWS VERSION = 7 File length = 1510 Rect size = (0, 0)-(20480, 15360) Frame rate = 30 Frame count = 1 SWF::Element::Tag::DefineBitsLossless->new( CharacterID => 1, FileName => 0, BitmapFormat => 5, BitmapWidth => 256, BitmapHeight => 64, ) SWF::Element::Tag::DefineShape->new( ShapeID => 2, ShapeBounds => SWF::Element::RECT->new( Xmin => 0, Ymin => 0, Xmax => 5120, Ymax => 1280, ), Shapes => SWF::Element::SHAPEWITHSTYLE1->new( FillStyles => SWF::Element::Array::FILLSTYLEARRAY1->new([ SWF::Element::FILLSTYLE1->new( FillStyleType => 65, BitmapID => 1, BitmapMatrix => SWF::Element::MATRIX->new( ScaleX => 20, ScaleY => 20, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 0, TranslateY => 0, ), ), # 0 ]), ShapeRecords => SWF::Element::Array::SHAPERECORDARRAY1->new([ SWF::Element::SHAPERECORD1::STYLECHANGERECORD->new( MoveDeltaX => 5120, MoveDeltaY => 1280, FillStyle1 => 1, ), # 0 SWF::Element::SHAPERECORDn::STRAIGHTEDGERECORD->new( DeltaX => -5120, DeltaY => 0, ), # 1 SWF::Element::SHAPERECORDn::STRAIGHTEDGERECORD->new( DeltaX => 0, DeltaY => -1280, ), # 2 SWF::Element::SHAPERECORDn::STRAIGHTEDGERECORD->new( DeltaX => 5120, DeltaY => 0, ), # 3 SWF::Element::SHAPERECORDn::STRAIGHTEDGERECORD->new( DeltaX => 0, DeltaY => 1280, ), # 4 ]), ), ) SWF::Element::Tag::DefineSprite->new( SpriteID => 3, FrameCount => 1, ControlTags => SWF::Element::Array::TAGARRAY->new([ SWF::Element::Tag::PlaceObject2->new( Flags => 6, Depth => 1, CharacterID => 2, Matrix => SWF::Element::MATRIX->new( ScaleX => 1, ScaleY => 1, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 0, TranslateY => 0, ), ), # 0 SWF::Element::Tag::ShowFrame->new( ), # 1 SWF::Element::Tag::End->new( ), # 2 ]), ) SWF::Element::Tag::DefineButton2->new( ButtonID => 4, Flags => 0, Characters => SWF::Element::Array::BUTTONRECORDARRAY2->new([ SWF::Element::BUTTONRECORD2->new( ButtonStates => 1, CharacterID => 3, PlaceDepth => 1, PlaceMatrix => SWF::Element::MATRIX->new( ScaleX => 1, ScaleY => 1, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 0, TranslateY => 0, ), ColorTransform => SWF::Element::CXFORMWITHALPHA->new( Flags => 2, RedMultTerm => 205, GreenMultTerm => 205, BlueMultTerm => 205, AlphaMultTerm => 205, ), ), # 0 SWF::Element::BUTTONRECORD2->new( ButtonStates => 2, CharacterID => 3, PlaceDepth => 1, PlaceMatrix => SWF::Element::MATRIX->new( ScaleX => 1, ScaleY => 1, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 0, TranslateY => 0, ), ColorTransform => SWF::Element::CXFORMWITHALPHA->new( Flags => 0, ), ), # 1 SWF::Element::BUTTONRECORD2->new( ButtonStates => 4, CharacterID => 3, PlaceDepth => 1, PlaceMatrix => SWF::Element::MATRIX->new( ScaleX => 1, ScaleY => 1, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 40, TranslateY => 40, ), ColorTransform => SWF::Element::CXFORMWITHALPHA->new( Flags => 0, ), ), # 2 SWF::Element::BUTTONRECORD2->new( ButtonStates => 8, CharacterID => 2, PlaceDepth => 1, PlaceMatrix => SWF::Element::MATRIX->new( ScaleX => 1, ScaleY => 1, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 40, TranslateY => 40, ), ColorTransform => SWF::Element::CXFORMWITHALPHA->new( Flags => 0, ), ), # 3 ]), ) SWF::Element::Tag::PlaceObject2->new( Flags => 38, Depth => 1, CharacterID => 4, Matrix => SWF::Element::MATRIX->new( ScaleX => 1, ScaleY => 1, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 7925, TranslateY => 7026, ), Name => "swf_test_btn", ) SWF::Element::Tag::DefineBitsLossless->new( CharacterID => 5, FileName => 1, BitmapFormat => 5, BitmapWidth => 256, BitmapHeight => 64, ) SWF::Element::Tag::DefineShape->new( ShapeID => 6, ShapeBounds => SWF::Element::RECT->new( Xmin => 0, Ymin => 0, Xmax => 5120, Ymax => 1280, ), Shapes => SWF::Element::SHAPEWITHSTYLE1->new( FillStyles => SWF::Element::Array::FILLSTYLEARRAY1->new([ SWF::Element::FILLSTYLE1->new( FillStyleType => 65, BitmapID => 5, BitmapMatrix => SWF::Element::MATRIX->new( ScaleX => 20, ScaleY => 20, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 0, TranslateY => 0, ), ), # 0 ]), ShapeRecords => SWF::Element::Array::SHAPERECORDARRAY1->new([ SWF::Element::SHAPERECORD1::STYLECHANGERECORD->new( MoveDeltaX => 5120, MoveDeltaY => 1280, FillStyle1 => 1, ), # 0 SWF::Element::SHAPERECORDn::STRAIGHTEDGERECORD->new( DeltaX => -5120, DeltaY => 0, ), # 1 SWF::Element::SHAPERECORDn::STRAIGHTEDGERECORD->new( DeltaX => 0, DeltaY => -1280, ), # 2 SWF::Element::SHAPERECORDn::STRAIGHTEDGERECORD->new( DeltaX => 5120, DeltaY => 0, ), # 3 SWF::Element::SHAPERECORDn::STRAIGHTEDGERECORD->new( DeltaX => 0, DeltaY => 1280, ), # 4 ]), ), ) SWF::Element::Tag::DefineSprite->new( SpriteID => 7, FrameCount => 1, ControlTags => SWF::Element::Array::TAGARRAY->new([ SWF::Element::Tag::PlaceObject2->new( Flags => 6, Depth => 1, CharacterID => 6, Matrix => SWF::Element::MATRIX->new( ScaleX => 1, ScaleY => 1, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 0, TranslateY => 0, ), ), # 0 SWF::Element::Tag::ShowFrame->new( ), # 1 SWF::Element::Tag::End->new( ), # 2 ]), ) SWF::Element::Tag::DefineButton2->new( ButtonID => 8, Flags => 0, Characters => SWF::Element::Array::BUTTONRECORDARRAY2->new([ SWF::Element::BUTTONRECORD2->new( ButtonStates => 1, CharacterID => 7, PlaceDepth => 1, PlaceMatrix => SWF::Element::MATRIX->new( ScaleX => 1, ScaleY => 1, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 0, TranslateY => 0, ), ColorTransform => SWF::Element::CXFORMWITHALPHA->new( Flags => 2, RedMultTerm => 205, GreenMultTerm => 205, BlueMultTerm => 205, AlphaMultTerm => 205, ), ), # 0 SWF::Element::BUTTONRECORD2->new( ButtonStates => 2, CharacterID => 7, PlaceDepth => 1, PlaceMatrix => SWF::Element::MATRIX->new( ScaleX => 1, ScaleY => 1, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 0, TranslateY => 0, ), ColorTransform => SWF::Element::CXFORMWITHALPHA->new( Flags => 0, ), ), # 1 SWF::Element::BUTTONRECORD2->new( ButtonStates => 4, CharacterID => 7, PlaceDepth => 1, PlaceMatrix => SWF::Element::MATRIX->new( ScaleX => 1, ScaleY => 1, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 40, TranslateY => 40, ), ColorTransform => SWF::Element::CXFORMWITHALPHA->new( Flags => 0, ), ), # 2 SWF::Element::BUTTONRECORD2->new( ButtonStates => 8, CharacterID => 6, PlaceDepth => 1, PlaceMatrix => SWF::Element::MATRIX->new( ScaleX => 1, ScaleY => 1, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 40, TranslateY => 40, ), ColorTransform => SWF::Element::CXFORMWITHALPHA->new( Flags => 0, ), ), # 3 ]), ) SWF::Element::Tag::PlaceObject2->new( Flags => 38, Depth => 3, CharacterID => 8, Matrix => SWF::Element::MATRIX->new( ScaleX => 1, ScaleY => 1, RotateSkew0 => 0, RotateSkew1 => 0, TranslateX => 7925, TranslateY => 5586, ), Name => "task_test_btn", ) SWF::Element::Tag::ShowFrame->new( ) SWF::Element::Tag::End->new( )

Edit: g0n - code tags

Replies are listed 'Best First'.
Re: SWF-File-0.42 : Building a SWF from PNG via a text file
by Anonymous Monk on Dec 10, 2007 at 05:00 UTC
    dumpswf.plx - Parse SWF file and dump it as a perl script.
      Well dumpswf kind of makes a similar output to the above in header form, but it makes the zlibdata purely as a jpegstream. The code I have listed above is trying to create a SWF from PNG. I'm not trying to go the other way. Besides, if you look at the code, there are commands present that dumpswf wouldnt use, like filename=> and pngdatatable
        create a swf that does what you need using flash tools, then convert to perl script
      umm thanks for the reply but I think you missed the point again. The perl script above has come from another source, I am NOT trying to create the script - Im trying to get it to work to see the animation ! I already have the png files it uses for sprites.