So today I had to work on some graphics for an XNA project we are are doing. Its a small project and some of the animations I had wanted to do would be way easier to create in Flash CS4 rather than going through the math equations to make them work in XNA. So I started the endeavor of adding Flash to an XNA programming project.
First off, XNA version 4 does not have a library suited to Flash (due out in version 5 in Fall!). So I had to find a way to do it myself. I found a few SWF implementations but they were rather lengthy to add and were outside the scope of the project. I didn’t want to spend 9/10′s of the time alotted just to implement swf’s, so I did a quick workaround.
First off, I made my Flash animations in CS4. Then I went ahead and found this nifty tool… Magic SWF2Gif. I imported my freshly made SWF file chose the available file formats and it output all my animation into static images frame by frame. Now I have a folder full of images but I would like them to be in a different file format so now its time to fire up Photoshop. Using the actions panel I setup a little automation script to ‘save as’ the files and make them format as jpg and the quality I want. Save the script and batch process the folder and now the 250 individual frame by frame image files are all converted to the format I want to work with. Finally, I just import my images into my XNA project and setup code to run them as a sequence and now we have Flash into XNA, the quick and dirty method.
Now some pitfalls I found with Magic SWF2GIF is that you cant use nested movie clips within your animation or else SWF2GIF will get caught in the loops and export thousands of images. We don’t want that, so you have to manually loop any movie clip animation and it is best to animate within the main timeline itself. Also it is a bit fun to play with the frame rate settings for quick speed changes and to cut down the number of images output.
Now I COULD have spent hours implementing a real SWF into XNA, making spritesheets and just having XNA do the animation itself, however, what I needed was so small and so easy to make in Flash that this shaved a tremendous amount of time off of my development allowing me to focus on other aspects of the project = efficiency.


