Changeset 179
- Timestamp:
- 03/18/07 19:31:26 (2 years ago)
- Files:
-
- trunk/as2/lib/com/modestmaps/core/Tile.as (modified) (4 diffs)
- trunk/as2/lib/com/modestmaps/core/TileGrid.as (modified) (16 diffs)
- trunk/as2/lib/com/modestmaps/io/LoadMovieThrottledRequest.as (modified) (1 diff)
- trunk/as2/lib/com/modestmaps/Map.as (modified) (3 diffs)
- trunk/as2/lib/com/modestmaps/mapproviders/AbstractMapProvider.as (modified) (1 diff)
- trunk/as2/lib/com/modestmaps/mapproviders/yahoo/AbstractYahooMapProvider.as (modified) (3 diffs)
- trunk/as2/lib/com/modestmaps/mapproviders/yahoo/YahooHybridMapProvider.as (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/as2/lib/com/modestmaps/core/Tile.as
r177 r179 133 133 if(!grid.paintingAllowed()) 134 134 return; 135 136 DispatchableInterface(grid.mapProvider).addEventObserver( this, AbstractMapProvider.EVENT_PAINT_COMPLETE, "onPaintComplete" ); 137 135 138 136 // cancel existing call, if any... 139 137 if(__paintCall) … … 155 153 156 154 // set up the proper clip to paint here 155 DispatchableInterface(grid.mapProvider).addEventObserver( this, AbstractMapProvider.EVENT_PAINT_COMPLETE, "onPaintComplete" ); 157 156 158 157 var clipId : Number = this.getNextHighestDepth(); … … 182 181 { 183 182 dcCoord = Coordinate( __displayClips[i].coord ); 183 184 184 if ( dcCoord.equalTo( this.coord ) ) 185 185 break; … … 192 192 } 193 193 194 dispatchEvent( EVENT_PAINT_COMPLETE );194 dispatchEvent( EVENT_PAINT_COMPLETE ); 195 195 } 196 196 } trunk/as2/lib/com/modestmaps/core/TileGrid.as
r177 r179 19 19 class com.modestmaps.core.TileGrid extends MovieClip 20 20 { 21 // Real maps use 256. 22 public static var TILE_WIDTH : Number = 256; 23 public static var TILE_HEIGHT : Number = 256; 24 21 25 private var map:Map; 22 26 … … 36 40 private var __overlappingMarkers:Object; 37 41 38 // Real maps use 256.39 public var tileWidth:Number = 256;40 public var tileHeight:Number = 256;41 42 42 // Allow (true) or prevent (false) tiles to paint themselves. 43 43 private var __paintingAllowed:Boolean; … … 131 131 { 132 132 grid: this, 133 width: tileWidth,134 height: tileHeight,133 width: TILE_WIDTH, 134 height: TILE_HEIGHT, 135 135 coord: coord 136 136 }; … … 164 164 { 165 165 grid: this, 166 width: tileWidth,167 height: tileHeight,166 width: TILE_WIDTH, 167 height: TILE_HEIGHT, 168 168 coord: initTileCoord 169 169 }; … … 354 354 355 355 } else { 356 point.x += tileWidth* (coord.column - tile.coord.column);356 point.x += TILE_WIDTH * (coord.column - tile.coord.column); 357 357 358 358 } … … 362 362 363 363 } else { 364 point.y += tileHeight* (coord.row - tile.coord.row);364 point.y += TILE_HEIGHT * (coord.row - tile.coord.row); 365 365 366 366 } … … 408 408 409 409 // distance in tile widths from reference tile to point 410 var xTiles:Number = (point.x - tile._x) / tileWidth;411 var yTiles:Number = (point.y - tile._y) / tileHeight;410 var xTiles:Number = (point.x - tile._x) / TILE_WIDTH; 411 var yTiles:Number = (point.y - tile._y) / TILE_HEIGHT; 412 412 413 413 // distance in rows & columns at maximum zoom … … 660 660 var wellHeight:Number = (100 / well._yscale) * height; 661 661 662 var targetCols:Number = Math.ceil(wellWidth / tileWidth) + 1 + 2 * tileBuffer;663 var targetRows:Number = Math.ceil(wellHeight / tileHeight) + 1 + 2 * tileBuffer;662 var targetCols:Number = Math.ceil(wellWidth / TILE_WIDTH) + 1 + 2 * tileBuffer; 663 var targetRows:Number = Math.ceil(wellHeight / TILE_HEIGHT) + 1 + 2 * tileBuffer; 664 664 665 665 // grid can't drop below 1 x 1 … … 748 748 749 749 for(var i:Number = 1; i < active.length; i += 1) { 750 active[i]._x = active[0]._x + (active[i].coord.column - active[0].coord.column) * tileWidth;751 active[i]._y = active[0]._y + (active[i].coord.row - active[0].coord.row) * tileHeight;750 active[i]._x = active[0]._x + (active[i].coord.column - active[0].coord.column) * TILE_WIDTH; 751 active[i]._y = active[0]._y + (active[i].coord.row - active[0].coord.row) * TILE_HEIGHT; 752 752 753 753 //log(active[i].toString()+' at '+active[i]._x+', '+active[i]._y+' vs. '+active[0].toString()); … … 842 842 newTile.coord = newTile.coord.down(); 843 843 844 newTile._x = referenceTile._x + (xOffset * tileWidth/ 2);845 newTile._y = referenceTile._y + (yOffset * tileHeight/ 2);844 newTile._x = referenceTile._x + (xOffset * TILE_WIDTH / 2); 845 newTile._y = referenceTile._y + (yOffset * TILE_HEIGHT / 2); 846 846 847 847 newTile._xscale = newTile._yscale = referenceTile._xscale / 2; … … 923 923 well.globalToLocal(point); // all tiles are attached to well 924 924 925 var xMin:Number = point.x - (1 + tileBuffer) * tileWidth;926 var yMin:Number = point.y - (1 + tileBuffer) * tileHeight;925 var xMin:Number = point.x - (1 + tileBuffer) * TILE_WIDTH; 926 var yMin:Number = point.y - (1 + tileBuffer) * TILE_HEIGHT; 927 927 928 928 point = new Point(width, height); … … 930 930 well.globalToLocal(point); // all tiles are attached to well 931 931 932 var xMax:Number = point.x + (0 + tileBuffer) * tileWidth;933 var yMax:Number = point.y + (0 + tileBuffer) * tileHeight;932 var xMax:Number = point.x + (0 + tileBuffer) * TILE_WIDTH; 933 var yMax:Number = point.y + (0 + tileBuffer) * TILE_HEIGHT; 934 934 935 935 for(var i:Number = 0; i < active.length; i += 1) { … … 944 944 // too far up 945 945 tile.panDown(rows); 946 tile._y += rows * tileHeight;946 tile._y += rows * TILE_HEIGHT; 947 947 touched = true; 948 948 949 949 } else if(tile._y > yMax) { 950 950 // too far down 951 if((tile._y - rows * tileHeight) > yMin) {951 if((tile._y - rows * TILE_HEIGHT) > yMin) { 952 952 // moving up wouldn't put us too far 953 953 tile.panUp(rows); 954 tile._y -= rows * tileHeight;954 tile._y -= rows * TILE_HEIGHT; 955 955 touched = true; 956 956 } … … 960 960 // too far left 961 961 tile.panRight(columns); 962 tile._x += columns * tileWidth;962 tile._x += columns * TILE_WIDTH; 963 963 touched = true; 964 964 965 965 } else if(tile._x > xMax) { 966 966 // too far right 967 if((tile._x - columns * tileWidth) > xMin) {967 if((tile._x - columns * TILE_WIDTH) > xMin) { 968 968 // moving left wouldn't put us too far 969 969 tile.panLeft(columns); 970 tile._x -= columns * tileWidth;970 tile._x -= columns * TILE_WIDTH; 971 971 touched = true; 972 972 } … … 1018 1018 newTileParams = {grid: lastTile.grid, coord: lastTile.coord.down(), 1019 1019 _x: lastTile._x, _y: lastTile._y + lastTile.height, 1020 width: tileWidth, height: tileHeight};1020 width: TILE_WIDTH, height: TILE_HEIGHT}; 1021 1021 1022 1022 createTile(newTileParams); … … 1058 1058 newTileParams = {grid: lastTile.grid, coord: lastTile.coord.right(), 1059 1059 _x: lastTile._x + lastTile.width, _y: lastTile._y, 1060 width: tileWidth, height: tileHeight};1060 width: TILE_WIDTH, height: TILE_HEIGHT}; 1061 1061 1062 1062 createTile(newTileParams); trunk/as2/lib/com/modestmaps/io/LoadMovieThrottledRequest.as
r177 r179 61 61 // Event Handlers 62 62 63 private function onLoad Complete( clip : MovieClip, httpStatus : Number ) : Void63 private function onLoadInit( clip : MovieClip, httpStatus : Number ) : Void 64 64 { 65 65 dispatchEvent( ThrottledRequest.EVENT_RESPONSE_COMPLETE, clip, url ); trunk/as2/lib/com/modestmaps/Map.as
r177 r179 126 126 127 127 // initial tile position, assuming centered tile well in grid 128 var initX:Number = (initTileCoord.column - centerCoord.column) * grid.tileWidth;129 var initY:Number = (initTileCoord.row - centerCoord.row) * grid.tileHeight;128 var initX:Number = (initTileCoord.column - centerCoord.column) * TileGrid.TILE_WIDTH; 129 var initY:Number = (initTileCoord.row - centerCoord.row) * TileGrid.TILE_HEIGHT; 130 130 var initPoint:Point = new Point(Math.round(initX), Math.round(initY)); 131 131 … … 157 157 158 158 // multiplication factor between horizontal span and map width 159 var hFactor:Number = (BR.column - TL.column) / (__width / grid.tileWidth);159 var hFactor:Number = (BR.column - TL.column) / (__width / TileGrid.TILE_WIDTH); 160 160 161 161 // multiplication factor expressed as base-2 logarithm, for zoom difference … … 166 166 167 167 // multiplication factor between vertical span and map height 168 var vFactor:Number = (BR.row - TL.row) / (__height / grid.tileHeight);168 var vFactor:Number = (BR.row - TL.row) / (__height / TileGrid.TILE_HEIGHT); 169 169 170 170 // multiplication factor expressed as base-2 logarithm, for zoom difference trunk/as2/lib/com/modestmaps/mapproviders/AbstractMapProvider.as
r176 r179 88 88 private function raisePaintComplete( clip : MovieClip, coord : Coordinate ) : Void 89 89 { 90 dispatchEvent( EVENT_PAINT_COMPLETE, clip, coord );90 dispatchEvent( AbstractMapProvider.EVENT_PAINT_COMPLETE, clip, coord ); 91 91 } 92 92 trunk/as2/lib/com/modestmaps/mapproviders/yahoo/AbstractYahooMapProvider.as
r177 r179 1 1 import com.modestmaps.core.Coordinate; 2 import com.modestmaps.core.TileGrid; 2 3 import com.modestmaps.geo.MercatorProjection; 3 4 import com.modestmaps.geo.Transformation; … … 24 25 } 25 26 27 /** 28 * Yahoo clips are 258x258 to deal with Flash pixel fudge, we mask and offset them by 29 * one pixel so they show up correctly. 30 */ 31 public function paint( clip : MovieClip, coord : Coordinate ) : Void 32 { 33 super.paint( clip, coord ); 34 35 clip.image._x = clip.image._y = -1; 36 createMask( clip ); 37 } 38 39 26 40 public function sourceCoordinate(coord:Coordinate):Coordinate 27 41 { … … 33 47 return new Coordinate(coord.row, wrappedColumn, coord.zoom); 34 48 } 49 50 private function createMask( clip : MovieClip ) : Void 51 { 52 var mask : MovieClip = clip.createEmptyMovieClip( "mask", clip.getNextHighestDepth() ); 53 with ( mask ) 54 { 55 moveTo(0, 0); 56 //lineStyle( 1, 0x000000 ); 57 beginFill(0x000000, 100); 58 lineTo(0, TileGrid.TILE_HEIGHT); 59 lineTo(TileGrid.TILE_WIDTH, TileGrid.TILE_HEIGHT); 60 lineTo(TileGrid.TILE_WIDTH, 0); 61 lineTo(0, 0); 62 endFill(0, 0); 63 } 64 clip.setMask( mask ); 65 } 35 66 } trunk/as2/lib/com/modestmaps/mapproviders/yahoo/YahooHybridMapProvider.as
r176 r179 18 18 } 19 19 20 /** 21 * Yahoo clips are 258x258 to deal with Flash pixel fudge, we mask and offset them by 22 * one pixel so they show up correctly. 23 */ 20 24 public function paint( clip : MovieClip, coord : Coordinate ) : Void 21 25 { … … 35 39 request.send(); 36 40 37 //createLabel( clip, coord.toString() ); 41 clip.bg._x = clip.bg._y = -1; 42 clip.overlay._x = clip.overlay._y = -1; 43 44 createMask( clip ); 38 45 } 39 46 … … 59 66 } 60 67 68 private function isClipLoaded( clip : MovieClip ) : Boolean 69 { 70 return ( clip.getBytesTotal() > 0 && clip.getBytesLoaded() == clip.getBytesTotal() ); 71 } 72 61 73 // Event Handlers 62 74 63 75 private function onResponseComplete( clip : MovieClip, coordinate : Coordinate ) : Void 64 76 { 65 if ( clip.bg._loaded && clip.overlay._loaded ) 77 // HAKT 78 var bgClip : MovieClip = clip._parent.bg; 79 var overlayClip : MovieClip = clip._parent.overlay; 80 81 if ( isClipLoaded( bgClip ) && isClipLoaded( overlayClip ) ) 82 { 66 83 raisePaintComplete( clip._parent, coordinate ); 84 } 67 85 } 68 86 }
