Flash Lite JPG2SWF source

If you develop for Flash Lite 1.1, FlashLite Writer Toolkit is a very good and very simple solution for converting JPG files to SWFS on the fly.

For the last year I have been using Flash Writer Toolkit from bronson beta. I’ve been very pleased with it. It is super easy to use, it only has three small PHP files and has no dependencies on any other libraries. I have however been a bit tight lipped on it though, not because I didn’t want to tell people how cool it was but because it had one serious flaw.

The PHP file is old. If was made in the days of solving the problem in Flash 5. Because of that, you have to make a small modification to let the file even open in Flash Lite (based on the flash 4 player). Beyond that though was the more serious issue that It was built for an older version of PHP. Methods like fopen work differently now and the tool simply didn’t work in the newer versions of PHP.

My skills at PHP are very much in the dabbling area and debugging an application that is reconstructing a binary file was really not going to be an afternoon project for me. Laziness won out and I just installed an old version of PHP. Finally I’ve gotten around to tweaking the original source and the example to be particularly useful for Flash Lite.

It turns out that there really wasn’t much to change, but since posting a revised copy is much easier than explaining what to change over and over, here you go. ;)

To use the files, just drop all three in a directory on a webserver running PHP. You should only need to modify the jpg2swf.php file. You just supply a URL and you are off to the races. When laziness is beaten back once more, I really need to add support for the GD libraries to resize images, auto rotate them and do all the other fun stuff that GD 2 does.

Thanks to Henri who mercifully ended my confusion on several PHP things.

6 thoughts on “Flash Lite JPG2SWF source

  1. Pingback: Justin’s Rich Media Blog » Flash Lite Flickr Search

  2. This is great Justin i was using swf tools to convert images but on the linux server i had no chance, Now all i need is to figure how this works.

  3. Hi.
    Im attempting to run the jpg2swf code on IIS.
    I can run PHP files without a problem but when I use the jpg2swf code all I get back when called is a bunch of jibberish in the browser.
    Also, what should populate the . $_GET["id"]; section ?

    example return

    FWSuhp` CÿÿÿÿÙÿØÿØÿàJFIFHHÿÛC       ÿÛC  ÿÀp–ÿÄÿÄK”#2BRbr3Cs‚!$%1AQcƒ’¢£³ÂÒÓð4S“²ÃâDaq”áãÿÄÿÄ#!1”2AÿÚ ?ù fn‘/ý8P¸gÏDê¶¾zμoDàiܬ?pó(˜7»Ó¹„Êp˜ºTÔÂLèÄ3:a&OHkŠŸ’nj©£–q ¼³Dêì~ä‡a–‹Afžk)¤#§çÚ o³É{v¨Ôv KS󔜒zAÖŠ—.ž»x`ƒWH€¶2·ÆgŠ©ŸB`‡J¯4ô2~99°ÓPl?¾ Â>õÚé7”Œó+f æ“D–G BÜ¥Up›]Ž=ŸŽE+G7· Ü“ ÿHÊœÈfïAÜšjn»¡tÕe •¨+Xэ1v*à•A`Åö%Xo죀̶F ¶Í4y6n8‚‘ñÕaªgT•¸MJTKªóIq¬D$tˆÁ2™ƒë½.Ó A;TÙÓíBL¬£[µ$ʐ€ìüìjX„G’:ü½%EºyxCÜŽ„1Úm# ¤Õü7ØŠ26íˤÊH[¨¡Y­`žéžÿr¸áçË1vÚà`Ü˧ “™,šÄD[êXuÇRgøÂÞ\ ¢¬

  4. hi justin,
    i’m using flashwriter toolkit provided by u and it is generating the swf.

    But when i try to load it into the flashlite it is giving me an error. so any settings required for this problem.

  5. Pingback: The Life of Bryan » Blog Archive » Flash Lite Friday Digest #8

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>