Changeset 639

Show
Ignore:
Timestamp:
08/14/08 12:19:57 (3 months ago)
Author:
allens
Message:

added getCoordTile(), and added ProgressEvent? dispatches for tile loading progress

Files:

Legend:

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

    r635 r639  
    1212        import flash.events.IOErrorEvent; 
    1313        import flash.events.MouseEvent; 
     14        import flash.events.ProgressEvent; 
    1415        import flash.geom.Matrix; 
    1516        import flash.geom.Point; 
     
    220221                         
    221222                        well = new Sprite(); 
     223                        well.name = 'well'; 
    222224                        well.doubleClickEnabled = true; 
    223225                        well.mouseEnabled = true; 
     
    228230                         
    229231                        addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);                  
     232                } 
     233                 
     234                /** 
     235                 * Get the Tile instance that corresponds to a given coordinate. 
     236                 */ 
     237                public function getCoordTile(coord:Coordinate):Tile 
     238                { 
     239                    // these get floored when they're cast as ints in tileKey() 
     240                    var key:String = tileKey(coord.column, coord.row, coord.zoom); 
     241                    return well.getChildByName(key) as Tile; 
    230242                } 
    231243                 
     
    689701                                dispatchEvent(new MapEvent(MapEvent.BEGIN_TILE_LOADING)); 
    690702                        } 
    691                         else if (previousOpenRequests > 0 && openRequests.length == 0) { 
    692                                 dispatchEvent(new MapEvent(MapEvent.ALL_TILES_LOADED)); 
    693                                 // request redraw to take parent and child tiles off the stage if we haven't already 
    694                                 dirty = true; 
     703                        else if (previousOpenRequests > 0) 
     704                        { 
     705                            // dispatch tile load progress 
     706                            dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS, false, false, previousOpenRequests - openRequests.length, previousOpenRequests)); 
     707 
     708                            // if we're finished... 
     709                            if (openRequests.length == 0) 
     710                            { 
     711                                    dispatchEvent(new MapEvent(MapEvent.ALL_TILES_LOADED)); 
     712                                // request redraw to take parent and child tiles off the stage if we haven't already 
     713                                dirty = true; 
     714                        } 
    695715                        } 
    696716