Ken Hawkins, formerly of The Post and Courier newspaper (Charleston, SC) helped me figure out how to take GIS shapefile data (point, line, and polygon) prepped in ArcMap or similar, process it in Illustrator using the Avenza MaPublisher plugin, and then copy-paste import into Flash CS3+ and apply the Instance_setMcName script. I first saw his handywork in the http://www.charleston.net/graphics/200802_primary/ map which is illustrated at the top of this post. I first learned of this technique last year but I think it is still relevant so am posting it now.

Free command script called “Instance_setMcName”. Before you start, download the script from Adobe, registration required (alternate download, no registration required) and double click file icon to install the script into Flash. Relaunch Flash to enable the script.

Overview:

Shapefile prep work in ArcMap GIS as needed.

Import the shapefile (.shp) in Illustrator using MaPublisher. Each geographic feature imports as it’s own path object in illustrator, visible in the Layers panel when it is set to not just show top level layers.

Use MaPublisher to name each map object’s GIS database attribute to name itself.

Import the Illustrator file to Flash .

Run the script to take the movieclip names and apply them to instances.

Open the MapAttributes panel by going to View > MaPublisher > MapAttributes.

In your MapAttributes panel, use the flyout menu to select Edit Schema.

Select the #Name (usually selected by default) in the list of columns.

Check the box marked “Derive value from expression”

Click the “…” button.

In the resulting dialog’s text entry field, type in the name of the field you want to use to name the individual polygons (county, precinct, etc.). This is case sensitive.

Hit OK twice.

Watch as your individual path objects are named in the Layers panel then save the file.

Open Flash and import the AI file to the stage (File > Import).

In the Import dialog box, select all the sublayers and check the box named “Create movie clip” and hit OK. The map will be imported both onto the stage and each map object will be added to the document’s Library.

In the Library panel, select all the MovieClips in the Illustrator Import sub-folder and drag them up and out of the folders to the top level.

Use Edit > Select All to select all your map object symbols on the stage.

Under “Commands” in the top menu, select “Instance_setMcName.”

All you symbol instances will be named the same as their parent movieClip libary item. Use the Properties panel to verify this.

Both Ken and I have used this process on multiple shapefiles with hundreds of objects and it’s worked like a dream.

Caution on Numeric Names:

Some GIS shapefiles have category names that begin with numbers, which Flash doesn’t like. Flash is picky about some other characters starting off the name, too, so when in doubt, use the following solution.

You can edit the schema to add a letter in front of each name and then use actionscript to do the same to each item in your XML file. A little cloogy but better than the alternative.

Click the Add button in the Edit Schema window in MaPublisher’s Illustrator panel

Name the new column “a”. Make sure the Type is string and enter “a” for the value (the derive value button must be unchecked to see this option).

Press enter.

Select #Name column.

Find the expression field in the same dialog and type out “a&PRECINCT” (where “a” is the “a” attribute column name and PRECINCT is the attribute column name). Note: the & symbol is used to concatenate (add together) the string values in each attribute column.

Press enter.

Verify the name changes in the Layers panel.

Seperate Stroke and Fill Workflow:

To have a seperate stroke layer on polygons so the fills can be color coded seperately from the strokes (which would always maintain the same stroke color) you’ll need to make a 2nd copy of the symbols:

In Illustrator after you’ve used MaPublisher to name all your polygons appropriately, duplicate the layer and hide/lock the original layer.

Give the new polygons a stoke and no fill, and rename them using Steps 3-6 except append the naming scheme with “Stroke”

Import the Illustrator file to Flash. Two groups of symbols are imported.One group’s symbols will be named something like “precinct234″ and the other group’s corresponding symbols will be named “precinct234Stroke”

Flash can now be instructed via ActionScript coding to independently control a symbols fill and whether or not it is “highlighted” with a stroke.

Bonus Feature!

Use MaPublisher to import other GIS layers (roads, polling locations, etc.) and they will land directly on top of the thematic symbols. I recommend doing this in the same import session, or before you rescale the maps. Best results when all GIS shapefiles are already in the same projection.

To set up your XML which is used to import your map data values (essentially an XML version of your DBF file associated with the shapefile),check out Layne’s thread.

Flash.app does have a bug when opening a MC with tons of MC in it. Make sure u have your map features not loose on the stage but inside a grouping MC. As long as flash only deals with grouping mc, the speed is only issue when making occasional edits inside the map. (I had only emailed Matt back before, now adding to comments.)

Yes, if you have a crazy big shapefile of the map geometry, run it thru http://mapshaper.org/, it will do a better job than Illustrator’s simplify paths, especially if you have precinct boundaries you need to zoom into where having border lines on top of each other (instead of jogging back and forth over each other) is key.

This is a great tutorial Nathan. I have a question, after you import the mc’s into Flash how do you control a symbols stroke color? I’m new to ActionScript, so I’m struggling a bit. I tried using lineStyle, but it doesn’t seem to work.