Using Xinf to embed SVG content via Flash
SVG is a widely-used, open, XML-based format for vector graphics. The state of SVG rendering in various browsers (so it exists), varies widely. With Xinf, you can utilize Adobe's Flash Player (v9+) to embed SVG content in you web page easily, and with consistent rendering results. Today.
An in-action example can be seen here.
Using 'Xinf SVG Viewer'
'Xinf SVG Viewer' is a single, <60k SWF file that can be used without recompiling to embed SVG content using Flash. It needs to be parameterized with a path to the SVG file to display, and optionally Background color, and color and content of a "Loading..." message that will be displayed while the SVG file is being loaded and parsed. An example (Firefox-tested) embed might look like this:
<embed src="svgviewer.swf"
width="320"
height="240"
FlashVars="src=test.svg"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"
/>
In reality, you might want to use something like SWFObject, or your preferred embedding technology, to embed Flash player.
Here's the list of parameters that svgviewer.swf currently takes:
| Parameter | Example | Default | Description |
| src | test.svg | (none) | URL (relative to svgviewer.swf, i think) of the SVG file to show. Usual Flash security restrictions apply |
| backgroundColor | 0x00aa00 | (white) | Background Color |
| loadMessage | Please%20Wait... | Loading... | Message to display while the SVG file is loading |
| loadMessageColor | 0xff0000 | (dark gray) | Color of the loadMessage |
Getting the SVG Viewer SWF
The latest Version of the Xinf SVG Viewer SWF is available directly from Xinf SVN: http://xinf.org/trac/browser/trunk/samples/flash-svg/svgviewer.swf?format=raw.
It is published with the same license as Xinf itself (LGPL+LE), so you might use it quite unlimited-ly for commercial or noncommercial applications, but if you modify the source code, you should publish your changes (or feed them back to the Xinf project).
For questions and comments, please use the Xinf Mailing List as described on WikiStart.
Limits
- Xinf's SVG support is quite far, but not perfect. In particular, EcmaScript scripting is not supported, and neither are SVG Animation or Bitmap filter effects (yet). Still, most static SVG content should render fine.
- Xinf uses haXe's XML parser to parse SVG content. For big files, it might be a little slow.
