Search code examples
actionscript-3flashesri

Convert Shapefile in Flash MovieClip


A colleague and I have successfully projected data from ESRI shapefile onto stage in Flash (for a web-based app) using the ShpMap class (http://andywoodruff.com/blog/simple-shapefile-drawing-in-actionscript-3/).

However, now we would like to convert the shapefile directly into a MovieClip that can be stored in a library (and use attributes in .dbf to autoname them). Any idea if this is possible and/or ideas for modifying the source code to achieve this?


Solution

  • You cannot. The library can only store ESRI files as ByteArrays, and the MovieClips (Sprites, to be more precise) are created only at runtime. So your best action would be create an array out of your desired maps as class names in library, a paired array of DBF ByteArray class names, and use each pair instead of your library reference. You will then have to remake ShpMap class to accept readymade ByteArrays as parameters for its constructor, so that it won't use URLRequests to retrieve the data, but take it as provided. Note though, the loading and parsing of the ByteArray is still asynchronous, so you will still employ Loader.load() method and event listeners.