4

I have an actionscript that reads an swf and goes through movieclips in it.

The movie clips should be simple shapes. I want to convert the data in these movieclips to a polygon. In other words, I want a series of coordinates that represent the shapes on the movieclip.

Joe
  • 7,922
  • 18
  • 54
  • 83

1 Answers1

4

There's no easy way to do this. Once a shape is drawn to the stage, the only graphical information you can access is the rendered pixel bitmap; all vector information is lost.

To transform shapes into polygons, you'll have to either analyze the ActionScript byte code stored in the SWF file (find and extract the bytes that contain vector drawing information and use it to re-create the shapes in code), or use the color info in the bitmaps to trace shapes (which is never going to be fully accurate, as you might guess).

Either way, this is not a simple task.

weltraumpirat
  • 22,544
  • 5
  • 40
  • 54
  • 1
    Hmm. Do you know how to access the bitmap? Also, I'm using this library: https://github.com/claus/as3swf to try to analyze the information in the SWF file. Is there any way to see which vector image is for a specific movieclip? – Joe Oct 16 '12 at 14:53
  • 2
    Accessing the pixels is easy: Create a new BitmapData object of the required size, then use `BitmapData#draw()` to render the pixel data. That library looks promising, but I'm afraid I haven't tried it. Why don't you just send the author a message? Perhaps he's willing to help. ;) – weltraumpirat Oct 16 '12 at 15:00