Changeset 600

Show
Ignore:
Timestamp:
07/16/08 13:33:31 (2 months ago)
Author:
tom
Message:

RIP Reactor, you will be missed but this branch doesn't need you any more

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/tom-tweenlite/lib/com/modestmaps/core/TileGrid.as

    r599 r600  
    187187                        addChild(well); 
    188188 
    189 /*                      worldMatrix = new Matrix(); 
    190                         worldMatrix.translate(_panX,_panX); 
    191                         worldMatrix.scale(_scale,_scale); 
    192                         worldMatrix.translate(mapWidth/2, mapHeight/2); */ 
    193  
    194189                        worldMatrix = new Matrix(); 
    195 /*                      worldMatrix.translate(-provider.tileWidth/2, -provider.tileHeight/2); 
    196                         worldMatrix.scale(1, 1); 
    197                         worldMatrix.translate(mapWidth/2, mapHeight/2); */ 
    198190                         
    199191                        addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);                  
     
    253245                        } 
    254246                         
    255 //                      if (!panning && !zooming) { 
    256                                 processQueue(); 
    257 //                      }                                
    258                          
     247                        processQueue();                  
    259248                } 
    260249                 
     
    275264                                }                        
    276265                                else { 
    277                                         trace("panning but no startPan"); 
     266                                        // TODO: this should probably be an error, but I'm not convinced that it can't happen yet :) 
     267                                        //trace("panning but no startPan"); 
    278268                                }                
    279269                        }        
     
    284274                dispatchEvent(zoomEvent); 
    285275                        } 
    286                          
    287                         //var startTime:Number = getTimer(); 
    288276                         
    289277                        // TODO: 
     
    456444                                                if (stillNeedsAnImage) { 
    457445                                                        blankCount++; 
    458                                                         //trace("sorry, no parent known for", key); 
    459446                                                } 
    460447 
     
    534521 
    535522                        dirty = false; 
    536                          
    537                         //trace((getTimer() - startTime)/1000.0, "seconds in TileGrid.onRender"); 
    538523 
    539524                } 
     
    683668                        else { 
    684669                                // TODO: keep it around since we did the work 
    685                                 // only if it didn't have more overlays to come                          
    686 //                              trace("\t \t !!! parent already removed:", loader.name); 
    687 //                              trace("\t \t !!! tl/br:", topLeftCoordinate, bottomRightCoordinate); 
     670                                //       but only if it didn't have more overlays to come                                
    688671                        } 
    689672                        var index:int = openRequests.indexOf(loader); 
     
    695678                private function onLoadError(event:IOErrorEvent):void 
    696679                { 
    697                         //trace("\t \t !!! load error: ", event.text); 
    698680                        var foundLoader:Boolean = false; 
    699681                        var loaderInfo:LoaderInfo = event.target as LoaderInfo; 
     
    705687                                        if (tile) { 
    706688                                                delete layersNeeded[tile]; 
    707                                                 //trace("painting error"); 
    708689                                                tile.paintError(provider.tileWidth, provider.tileHeight); 
    709690                                                if (tile.zoom == currentZoom) { 
     
    864845                public function prepareForZooming():void 
    865846                { 
    866                         //trace(getTimer(), 'TileGrid.prepareForZooming'); 
    867847                        if (startZoom >= 0) { 
    868848                                doneZooming(); 
    869849                        } 
     850 
    870851                        startZoom = zoomLevel; 
    871852                        zooming = true; 
    872                         var event:MapEvent = new MapEvent(MapEvent.START_ZOOMING); 
    873                         event.zoomLevel = startZoom;  
    874                         dispatchEvent(event); 
     853  
     854                        dispatchEvent(new MapEvent(MapEvent.START_ZOOMING, startZoom)); 
    875855                } 
    876856                                         
    877857                public function doneZooming():void 
    878858                { 
    879                         //trace(getTimer(), 'TileGrid.doneZooming'); 
    880859                        startZoom = -1; 
    881860                        zooming = false; 
    882                         var event:MapEvent = new MapEvent(MapEvent.STOP_ZOOMING); 
    883                         event.zoomLevel = zoomLevel;  
    884                         dispatchEvent(event); 
     861 
     862                        dispatchEvent(new MapEvent(MapEvent.START_ZOOMING, zoomLevel)); 
    885863                } 
    886864 
    887865                public function resetTiles(coord:Coordinate, point:Point):void 
    888866                { 
    889                         //trace("resetTiles", coord, point); 
    890                          
    891867                        var sc:Number = Math.pow(2, coord.zoom); 
    892868 
    893869                        worldMatrix.identity(); 
    894                         //worldMatrix.translate( -mapWidth/2, -mapHeight/2 ); 
    895870                        worldMatrix.scale(sc, sc); 
    896871                        worldMatrix.translate(mapWidth/2, mapHeight/2 ); 
     
    898873                        worldMatrix.translate(-provider.tileWidth*coord.column, -provider.tileHeight*coord.row); 
    899874 
     875                        // reset the inverted matrix, request a redraw, etc. 
    900876                        dirty = true; 
    901                         // reset the worldMatrix 
    902                         //calculateMatrix(); 
    903877                } 
    904878 
     
    10291003                        minTy = tl.row * provider.tileHeight; 
    10301004                        maxTy = br.row * provider.tileHeight; 
    1031  
    1032                         //trace("bounds of useful map area: ", minTx, maxTx, minTy, maxTy);                      
    10331005                } 
    10341006                 
     
    10571029                         
    10581030                        if (rightX-leftX > maxTx-minTx) { 
    1059                                 //trace("CENTERING X"); 
    1060                                 //_panX = -(minTx+maxTx)/2; 
    10611031                                worldMatrix.tx = (mapWidth-(minTx+maxTx)*scale)/2; 
    10621032                                touched = true; 
    10631033                        } 
    10641034                        else if (leftX < minTx) { 
    1065                                 //trace("TOO LEFT"); 
    1066                                 //_panX += leftX-minTx; 
    10671035                                worldMatrix.tx += (leftX-minTx)*scale;                           
    10681036                                touched = true; 
    10691037                        } 
    10701038                        else if (rightX > maxTx) { 
    1071                                 //trace("TOO RIGHT"); 
    1072                                 //_panX += rightX-maxTx; 
    10731039                                worldMatrix.tx += (rightX-maxTx)*scale;                          
    10741040                                touched = true; 
     
    10791045 
    10801046                        if (downY-upY > maxTy-minTy) { 
    1081                                 //trace("CENTERING Y"); 
    1082                                 //_panY = -(minTy+maxTy)/2; 
    10831047                                worldMatrix.ty = (mapHeight-(minTy+maxTy)*scale)/2; 
    10841048                                touched = true; 
    10851049                        } 
    10861050                        else if (upY < minTy) { 
    1087                                 //trace("TOO HIGH"); 
    1088                                 //_panY += upY-minTy; 
    10891051                                worldMatrix.ty += (upY-minTy)*scale; 
    10901052                                touched = true; 
    10911053                        } 
    10921054                        else if (downY > maxTy) { 
    1093                                 //trace("TOO LOW"); 
    1094                                 //_panY += downY-maxTy; 
    10951055                                worldMatrix.ty += (downY-maxTy)*scale; 
    10961056                                touched = true; 
     
    11021062                                _bottomRightCoordinate = null;                           
    11031063                        } 
    1104  
    1105                         //trace("bounds of visible map area: ", leftX, rightX, upY, downY); 
    11061064 
    11071065                        return touched;                  
     
    11961154} 
    11971155 
    1198  
  • branches/tom-tweenlite/lib/com/modestmaps/Map.as

    r599 r600  
    3232        import com.modestmaps.mapproviders.IMapProvider; 
    3333        import com.modestmaps.mapproviders.microsoft.MicrosoftProvider; 
    34         import com.stamen.twisted.Reactor; 
    3534         
    3635        import flash.display.DisplayObject; 
     
    4241        import flash.geom.Point; 
    4342        import flash.geom.Rectangle; 
     43        import flash.utils.clearTimeout; 
     44        import flash.utils.setTimeout; 
    4445         
    4546    [Event(name="startZooming",      type="com.modestmaps.events.MapEvent")] 
     
    9495            public function Map(width:Number=320, height:Number=240, draggable:Boolean=true, mapProvider:IMapProvider=null, ... rest) 
    9596            { 
    96                 if (!Reactor.running()) 
    97                 { 
    98                         // should this really be fatal? 
    99                         //trace('com.modestmaps.Map.init(): com.stamen.Twisted.Reactor ought to be running at this point.'); 
    100                         Reactor.run(this, 100); 
    101                 } 
    102  
    10397                        if (!mapProvider) mapProvider = new MicrosoftProvider(MicrosoftProvider.ROAD); 
    10498 
     
    185179                grid.resetTiles(position.coord, position.point); 
    186180                onExtentChanged(this.getExtent()); 
    187             Reactor.callNextFrame(callCopyright); 
     181            requestCopyrightUpdate(); 
    188182            } 
    189183             
     
    211205                grid.resetTiles(center.coord, center.point); 
    212206                onExtentChanged(this.getExtent()); 
    213                 Reactor.callNextFrame(callCopyright); 
     207                requestCopyrightUpdate(); 
    214208            } 
    215209            } 
     
    236230                                grid.resetTiles(center.coord, center.point); 
    237231                                onExtentChanged(this.getExtent()); 
    238                                 Reactor.callNextFrame(callCopyright); 
     232                                requestCopyrightUpdate(); 
    239233                        } 
    240234        } 
     
    307301                var centerCoord:Coordinate = (new Coordinate(centerRow, centerColumn, centerZoom)).zoomTo(initZoom); 
    308302                 
    309                 trace("centering on", centerCoord); 
    310                  
    311303                return coordinatePosition(centerCoord); 
    312304                } 
     
    467459                } 
    468460                 
    469                 Reactor.callLater(1000,callCopyright); 
     461                requestCopyrightUpdate(); 
    470462            } 
    471463             
     
    615607                        grid.resetTiles(center.coord, center.point); 
    616608                        onExtentChanged(this.getExtent()); 
    617                         Reactor.callNextFrame(callCopyright); 
     609                        requestCopyrightUpdate(); 
    618610                } 
    619611 
     
    679671            } 
    680672             
     673            protected var copyrightTimeout:uint; 
     674             
     675            protected function requestCopyrightUpdate():void 
     676            { 
     677                if (copyrightTimeout) { 
     678                        clearTimeout(copyrightTimeout); 
     679                } 
     680                copyrightTimeout = setTimeout(callCopyright, 250); 
     681            } 
     682             
    681683           /** 
    682684            * Call javascript:modestMaps.copyright() with details about current view. 
     
    685687            protected function callCopyright():void 
    686688            { 
     689                if (copyrightTimeout) { 
     690                        clearTimeout(copyrightTimeout); 
     691                } 
     692                 
    687693                var cenP:Point = new Point(mapWidth/2, mapHeight/2); 
    688694                var minP:Point = new Point(mapWidth/5, mapHeight/5);