@@ -24,12 +24,14 @@ package net.systemeD.halcyon {
24
24
private var requests: Array =[];
25
25
private var tiles: Object = {}; // key is "z,x,y"; value "true" if queued, or reference to loader object if requested
26
26
private var waiting: int = 0 ; // number of tiles currently being downloaded
27
+ private var loadcount: int = 0 ; // number of tiles fully downloaded
27
28
private var baseurl: String ; // e.g. http://npe.openstreetmap.org/$z/$x/$y.png
28
29
private var scheme: String ; // 900913 or microsoft
29
30
public var blocks: Array ; // array of regexes which are verboten
30
31
31
32
private var map: Map;
32
- private const MAXTILEREQUESTS : int = 4 ;
33
+ private const MAXTILEREQUESTS : uint = 4 ;
34
+ private const MAXTILESLOADED : uint = 30 ;
33
35
34
36
private var sharpenFilter: BitmapFilter = new ConvolutionFilter (3 , 3 ,
35
37
[0 , -1, 0,
@@ -186,12 +188,25 @@ package net.systemeD.halcyon {
186
188
t. addEventListener (TimerEvent . TIMER ,function (): void { upFade(DisplayObject (event. target . loader )); });
187
189
t. start ();
188
190
waiting--;
191
+ loadcount++;
192
+ if (loadcount> MAXTILESLOADED ) purgeTiles();
189
193
return ;
190
194
}
191
195
192
196
protected function upFade (s :DisplayObject ):void {
193
197
s. alpha += 0.1 ;
194
198
}
199
+
200
+ protected function purgeTiles ():void {
201
+ for (var tile: String in tiles) {
202
+ var coords: Array = tile. split (',' ); var tz: uint = coords[ 0 ]; var tx : uint = coords[ 1 ]; var ty : uint = coords[ 1 ];
203
+ if (tz!= map . scale || tx < tile_l || tx > tile_r || ty < tile_t || ty < tile_b) {
204
+ if (tiles[ tile] . parent ) tiles[ tile] . parent . removeChild (tiles[ tile] );
205
+ delete tiles[ tile];
206
+ loadcount--;
207
+ }
208
+ }
209
+ }
195
210
196
211
197
212
// Assemble tile URL
0 commit comments