Skip to content
debreuil edited this page Sep 14, 2010 · 5 revisions

Once you’ve downloaded the Swf2XNA code, you can open the SwfNet.sln file in Visual Studio. Here you’ll see 19 projects. This is a code all involve working with swf files and converting between graphics formats.

The way it works is it takes a swf file, parses the tags into a C# object tree, and then converts this into an intermediate format called Vex. The vex format is designed to be easy to convert to most multimedia formats (rather than displayed). So for example it supports both cubic and quadratic bezier curves, it uses time rather than frame number for animation, and bitmaps (and bitmap fills) are stored as png/jpgs and referenced by path. This Vex format is then converted to GDI, Xaml, and XNA by the various projects. The conversions can go the other way to, though there isn’t code specifically doing that yet.

After this there are a few side projects that just linger around in there.

Here is an overview of each project:

  • GdiRenderer Takes in Vex objects and converts to WMF files using GDI+ (can convert to bitmaps as well, so use this for swf to bitmap).
  • SwfBitmapPacker Converts all the vector/bitmap objects in a swf to bitmaps, and then puts these in a single bitmap. Bitmaps can be faster to render on the gpu if they all come from a portion of a single bitmap. This was originally used for a Scaleform project, but will eventually be incorporated into swf2xna.
  • SwfDump Parses the tags of a swf, and dumps them out as text. Useful for debugging swfs.
  • SwfFormat This is the C# representation of the Swf file format. It supports everything up to v8, and some other things. It shouldn’t choke on newer formats, but you never know. This can both read and write swf files, though it has mostly been used for reading at this point.
  • SwfRenderer This is the startings of a swf renderer (allowing use of vectors at runtime in xna, rather than compile time bitmaps). Had an idea on how to convert beziers using scanline techniques quickly, but it wasn’t a great one. Will replace this with true scanline at one point (break to very short polygon edges first and then render). Here is an excellent paper on how to do this right.
  • SwfToXaml Converts swf files to XAML, including animation. This worked fine at one point, then didn’t work in the Expression editors after some update. I am bored with XAML, and using XML as the basis for a graphics format is painfully wrong imo, so doubt this will ever get updated by me. I doubt it works now, but there have only been minor changes to the vex format so it is probably just needing a cleanup.
  • V2DRuntime This is the C# equivalent of the Flash core library. It isn’t meant to be exact. It has a similar structure (DisplayObject, DispalyObjectContainer, Sprite, Movieclip etc), so it should be familiar to a Flash developer. This also pulls in swfs that have come through the content pipeline, and assigns them all to the proper classes and properties. It creates all the Box2D objects and joints. Lastly, it is a basic game engine for XNA. This is the main project you would use to make an XNA game with swf2xna.
  • V2DTests These are just basic example files of how you can create sprites and box2d objects with swf2xna. It originally held the tests, but now should probably be renamed.
  • Vex All conversions become a Vex object, and the Vex object is converted to anything else. This defines the Vex object.
  • VexFormat An old project that used JSFL to serialize a swf file, then Linq to analyze and adjust it, and then JSFL again to rebuild it. The idea was to have a nice find and replace tool for swfs, and to be able to add it to source control. XFL has kind of solved this problem now, I think.
  • VexPipeline Works with XNA Game Studio to allow swf files to be content. It is basically a wrapper for VexTo2DPhysics project, which uses many of the other projects here. It converts swfs into V2DWorld objects that the V2DRuntime can understand. It will also write all the bitmaps generated to the ‘exports/swfname’ folder, as well as an xml file that shows the object format (useful to understand wtf is going on with it all).
  • VexPipelineReader In XNA, projects can go to Windows or the XBox (or Zune and WinMobile7). Therefore it is important that Windows specific files used in content conversion aren’t referenced by the final game. This is why there is a ‘Reader’ project – games can use this on any platform to read in the digested swf – without needing to reference things like GDI which isn’t available on the XBox.
  • VexTo2DPhysics This converts the assets and structure of a swf into an object/xml file, and bitmaps. The final product of this could be used in non XNA environments like Unity or Flash itself.
  • XamlRenderer This takes in a Vex file and writes out a Xaml file. Zzzzzz.
  • XamlViewer This views Xaml files and swf files side by side, was used for debugging once.
  • XBox 360 Copy of Box2dXNA These are XBox builds of the projects above (XBox uses the compact framework, so it needs a different build). This is the same code as the above projects, just basically a different build file.
  • XBox 360 Copy of V2DRuntime
  • XBox 360 Copy of VexPipelineReader XBox version of VexPipelineReader.
Clone this wiki locally