I am currently porting a Flash game to the iPhone. The first stumbling block was getting assets out of Flash into a sprite sheet or for import into Zwoptex. Sure, Flash has functionality to export a movie to a series of PNG images, but it’s terrible. It cuts out animation unless you’re using Graphics (no MovieClips), which often means editing your graphics until they look wrong (no filters, etc.), and then there’s all the tedious cropping to do.
I wrote a small utility for myself that automatically renders out the symbols in a SWF to a series of PNG files, and optionally crops out the transparent bits around the edges as well as retaining the registration points of the items. I figured that this might be useful for others, so I’m putting it online now, along with source in case anybody wants to improve it.
It is a bit rough and ready. There’s very little in the way of error checking, and it might not work the way you want it to. Here are the caveats:
- This only works with AVM2 SWFs, so that’s Flash 9 player and higher with AS3
- It will only understand MovieClips on the timeline (no buttons!) and they must be exported for ActionScript for the filenames to be correct (this is easy enough to do with a few clicks in the Flash IDE).
- The program is memory-intensive. A bitmap is created for each frame of the SWF and held in memory until the files have been written (it was designed this way to facilitate cropping and quick development; it’s not intended as an export utility for your ten minute animations!)
- Timeline code that causes clips to loop infinitely will also cause the rendering to loop infinitely.
- Other stuff, probably
A suggested workflow:
- Create a new FLA file. Drag the movie clips that you want to export on to the stage.
- Publish a SWF.
- Run the SWF through SWFToPNG. You should now have an ordered series of PNGs representing each MovieClip on the stage
- Load these files into Zwoptex to create a sprite sheet and plist file for Zwoptex.
SWFToPNG is released under the terms of the GNU General Public License.
SWFToPNG Air Installer (sorry, it has to be AIR because Flex’s security restrictions would make the user have to run a file browse dialog for each file written)
SWFToPNG source code


#1 by Tony on April 16, 2010 - 01:52
thanks wayne, really helpful!
#2 by mousedown on December 17, 2010 - 14:52
This is great, thanks!
#3 by oscar on April 4, 2011 - 17:04
this air don’t work, before that I choose the folder happen nothing…
#4 by Stroncium on April 13, 2011 - 10:45
finally simple tool that does work, I always wondered why tehre is no such tool that would just grab whatever is in the swf player window. and now this works for the movieclip inside movieclip issue for animations.
#5 by wm on April 27, 2011 - 20:21
Thanks for spamming your child psychology site with inane comments (URLs edited out) and decreasing your reputation, Dr. Lewis-Snyder. And welcome to Akismet’s spam list.
#6 by Danielle on May 27, 2011 - 00:15
Hey, thanks for posting. I’ve been looking like a tool like this, and I’m definitely going to use your Install link for SWFToPNG. This is going to be great for fixing my movieclip issues.
-Danielle
Writer, [URL REMOVED]
#7 by Olli on September 21, 2011 - 09:21
Thanks a lot! That tool is really helpful for us…!!!!
#8 by Valdir Salgueiro on January 18, 2012 - 02:38
doesnt work, says swf needs to be a movie clip =/
#9 by wm on January 18, 2012 - 09:12
That’s not what that error message says. Please read the instructions again. There must be a clip with an export name defined on the stage.
#10 by Valdir Salgueiro on January 18, 2012 - 12:07
thanks for the prompt response, i have exported a “sprite” object from sothink flash decompiler, and this is the output i was testing to: http://www.gjteam.com.br/sprite185.swf
i also have the original fla file if needed
#11 by wm on January 18, 2012 - 22:39
That’s not what I mean by export :-)
I mean that the MovieClip on the stage must have a class name associated with it. Have a look at this image for an example: http://dl.dropbox.com/u/6127955/junk/export.png
If that doesn’t work, upload the FLA.
#12 by Valdir Salgueiro on January 19, 2012 - 04:01
thanks, still had no luck on this though, done all steps and rechecked again, this time it loads but memory goes up 3GB and never finishes processing, if you want to take a look in fla i will need your email since it has artist stuff and i dont think he would be happy if it was posted here =p
and here is the new swf: http://www.gjteam.com.br/movieclip.swf
must be something with my file =(
#13 by wm on January 20, 2012 - 12:25
Valdir,
I’ve looked at your FLA and I see that it’s the actual game! You need to create a separate FLA with each symbol you want to export to a spritesheet placed on the stage. None of the animations should loop, otherwise the tool will try to render out the frames until eternity like it did with your FLA of the full game.
What are you actually trying to do? It might be that this tool isn’t what you’re looking for.
#14 by Valdir Salgueiro on January 20, 2012 - 13:34
Hi, indeed i sent all the game, but what i was doing was clicking on the symbol, in this case (“nave colonizadora animada”) and “Export SWF…”. I thought it would gonna work this way
edit: the loop tip works :) now i have to figure out how to make the stage match the movieclip size
btw, what im trying to do is to export some sprites, i need to convert this game to android, thus will need the spritesheets with the effects already applied if possible. I havent touched flash until now so its a bit hard to wrap my head against it, your help is very appreciated!
#15 by wm on January 20, 2012 - 13:37
Oh cool, this tool might help you after all then :-)
The best thing to do is copy the symbols you want, put them in a new FLA, and set linkage names for each of them. Then export that SWF and run it through the tool, and cross your fingers!
#16 by wm on January 20, 2012 - 17:12
The artwork looked amazing, BTW!
#17 by Valdir Salgueiro on January 20, 2012 - 17:19
i agree :) i cnat take any credit on that though =p its fruit of the awesome job ph has done! his devianart: http://p-h.deviantart.com/gallery/