0 Replies Latest reply on Dec 3, 2010 12:17 AM by t5t6t7

    flash package - beginner question

    t5t6t7 Level 1

      hi, i have found this flash package to

      convert shapefiles  to flash but I am not sure what needs to be done with the flash package.  I have my

      shapefiles ready to go. Am i supposed to just paste this code in flash

      (making sure the .as is in the same folder as my shapefile) and voila, flash will convert the shapefile to .fla

      or .swf format?  Please explain what i need to be doing. Thanks


      here is the code:

      package {
          import com.cartogrammar.shp.ShpFeature;
          import com.cartogrammar.shp.ShpMap;
          import flash.display.Sprite;
          import flash.events.Event;
          import flash.geom.ColorTransform;
          [SWF(width='800', height='600', backgroundColor='#ffffff', frameRate='30')]
           * An example of drawing a simple map from a shapefile using my ShpMap class and Edwin van Rijkom's library.
           * @author Andy Woodruff (cartogrammar.com/blog)
          public class ShapefileExample extends Sprite
              private var map : ShpMap;
              public function ShapefileExample()
                  map = new ShpMap("data/STATES.shp","data/STATES.dbf");
                  map.addEventListener("map loaded",onMapLoaded);
                  map.addEventListener("attributes loaded",onAttributesLoaded);
              // Need to wait for the map to finish loading/drawing before it can be resized correctly.
              private function onMapLoaded(event:Event):void
                  map.scaleX = map.scaleY = map.width > map.height ? stage.stageWidth/map.width : stage.stageHeight/map.height;
                  // just for fun, add a marker to somewhere around my house!
                  addMarkerAt( 42.36,-71.11 );
              // To demonstrate retrieving a particular feature and doing something to it. This colors Wisconsin green.
              private function onAttributesLoaded(event:Event):void
                  var f : ShpFeature = map.getFeatureByAttribute("STATE_NAME","Wisconsin");
                  if (f != null){
                      var cTrans : ColorTransform = new ColorTransform();
                      cTrans.color = 0x009933;
                      f.transform.colorTransform = cTrans;
              // Super basic method for adding a green box at a specified lat/long.
              private function addMarkerAt( lat : Number, lon : Number )  : void
                  var box : Sprite = new Sprite();