0

I need to collect and import a mass of images into Flash. The cleanest way to do this seems to be using AS3SWF to create a timeline with 1 image per frame.

Does anyone have a code sample for something like this? AS3SWF looks great, but it's not heavy on documentation.

Justin Putney
  • 752
  • 1
  • 5
  • 16
  • Why bother with a timeline when you can load everything programatically with URLLoader? – Varnius Apr 17 '12 at 20:08
  • I need to load the sequence back into the Flash Pro IDE (not a SWF), but a SWF (as a transport format) is a cleaner way to get all of the images into the IDE using JSFL. – Justin Putney Apr 17 '12 at 20:12

1 Answers1

3

I played with AS3SWF a bit some time ago and found the SWF format specs (pdf) and documentation very useful. Still I didn't find it particularly easy as I don't have proper programming background/assembly experience.

There might be an easier way around your problem: SWFTools. They're a bunch of open source utilities, some of which might help you with your task, like jpg2swf and png2swf

I'm currently on OSX, so have downloaded the source and used the typical commands:

sudo ./configure
sudo make
sudo make install

I see for Windows there's an exe already, so it might be simpler. Still I imagine you'd call the utilities from command line. That can come in handy when using the undocummented fl.runCommandLine() function in JSFL. Here's a basic call to compile a swf 'slideshow' based on all the .png files on my desktop:

./png2swf -o ~/Desktop/desk.swf ~/Desktop/*.png

There are quite a few options for each utility, here an example:

jpeg2swf

Usage: ./jpeg2swf [-options [value]] imagefiles[.jpg]|[.jpeg] [...]

-o , --output <outputfile>     Explicitly specify output file. (otherwise, output.swf will be used)
-q , --quality <quality>       Set compression quality (1-100, 1=worst, 100=best)
-r , --rate <framerate>        Set movie framerate (frames per second)
-z , --zlib <zlib>             Enable Flash 6 (MX) Zlib Compression
-M , --mx                      Use Flash MX H.263 compression (use for correlated images)
-x , --xoffset <offset>        horizontally offset images by <offset>
-y , --yoffset <offset>        vertically offset images by <offset>
-X , --width <width>           Force movie width to <width> (default: autodetect)
-Y , --height <height>         Force movie height to <height> (default: autodetect)
-T , --flashversion <version>      Set flash file version to <version>
-v , --verbose <level>         Set verbose level to <level> (0=quiet, 1=default, 2=debug)
-V , --version                 Print version information and exit
-f , --fit-to-movie            Fit images to movie size
-e , --export <assetname>          Make importable as asset with <assetname>

Also, it might be worth taking a peak at this old(2004) article by Keith Peters.

George Profenza
  • 50,687
  • 19
  • 144
  • 218
  • That's interest stuff, George! Thanks for putting this together. +1 for the great details. I think if I end up exporting to individual PNGs (from AIR, which is where everything will start), I'll go straight to Flash with JSFL. Now if this tool could go from h.264 to SWF or PNG sequence...that would save me some time on this project. This is good to know for future projects anyhow! – Justin Putney Apr 17 '12 at 21:09
  • Hey Justin! Glad it helps. I still didn't fully understand what exactly you're trying to do to be honest. You can import an image sequence into the Flash IDE via JSFL I presume, but I can't see the need to write a .swf file before importing. Care to add details ? Off-topic: At some point I had a similar issue to [this](http://stackoverflow.com/questions/2031343/flex-how-to-count-colors-in-swf-vector-file) and got some quick t(w)ips from [Claus](http://twitter.com/#!/cwahlers). Might be worth a try for AS3SWF related things. – George Profenza Apr 17 '12 at 21:37
  • Thanks, George. I'm trying to keep things clean by writing a single file, but I think it's simpler just to write the PNGs and clean up the files after they've been imported. It's a complex conversion process made necessary by the fact that the Import Movie dialog is not accessible via JSFL. So, I'm loading the movie(s) into an AIR app, capturing frames, saving them as PNGs, then importing into Flash in sequence. – Justin Putney Apr 18 '12 at 00:25
  • Hmm, that sounds a bit familiar. When I tried to control the playback of videos in Flash, even embedded in the timeline, everything's smooth going forward(same/increased/decreased frame rate), but horribly slow playing backwards, caching the video on the fly as BitmapData instances did the trick. It's a shame the Import Movie dialog isn't accesible via JSFL. [Here](http://stackoverflow.com/questions/7450387/cs5-5-import-video-through-jsfl-without-video-wizard/7477495#7477495)'s a very hacky/fiddly/unstable workaround though. – George Profenza Apr 18 '12 at 07:44
  • 1
    Other options that I can think of are: Opening the video in After Effects and rendering as a PNG sequence - quite quick to setup, or quickly saving to a JPG sequence using [avidemux](http://fixounet.free.fr/avidemux/download.html) (free,opensource), but you get a bit of compression, not sure that's what you want. Those are the options with a GUI. If you install [ffmpeg](http://ffmpeg.org/download.html) (which ROCKS!), you can simply do this: `ffmpeg -i yourVideo.mov yourImage%d.png` from the command line. – George Profenza Apr 18 '12 at 07:53
  • Thanks, George. Very helpful. I actually got it working quite well. I load the movie into an FLVPlayback instance set the update rate to 1/3 the frame rate (to ensure every frame is hit--way more reliable than cuepoints), and only take one capture per video frame. Since the client is an animation studio, they've got the frame number listed on screen. So, it's easy to tell that it's capturing every frame. I was considering some command line option originally, but the Flash capture method is working quite well. – Justin Putney Apr 19 '12 at 15:45
  • That way it's less for the client to install, too. – Justin Putney Apr 19 '12 at 15:45