@@ -48,22 +48,23 @@ var ImageFile = new Class({
4848 // this.load.image({ key: 'bunny' });
4949 // this.load.image({ key: 'bunny', extension: 'jpg' });
5050
51- function ImageFile ( key , url , path , xhrSettings , config )
51+ function ImageFile ( loader , key , url , xhrSettings , config )
5252 {
5353 var fileKey = ( typeof key === 'string' ) ? key : GetFastValue ( key , 'key' , '' ) ;
5454
5555 var fileConfig = {
5656 type : 'image' ,
57+ cache : loader . textureManager ,
5758 extension : GetFastValue ( key , 'extension' , 'png' ) ,
5859 responseType : 'blob' ,
5960 key : fileKey ,
6061 url : GetFastValue ( key , 'file' , url ) ,
61- path : path ,
62+ path : loader . path ,
6263 xhrSettings : GetFastValue ( key , 'xhr' , xhrSettings ) ,
6364 config : GetFastValue ( key , 'config' , config )
6465 } ;
6566
66- File . call ( this , fileConfig ) ;
67+ File . call ( this , loader , fileConfig ) ;
6768 } ,
6869
6970 onProcess : function ( callback )
@@ -95,6 +96,13 @@ var ImageFile = new Class({
9596 } ;
9697
9798 File . createObjectURL ( this . data , this . xhrLoader . response , 'image/png' ) ;
99+ } ,
100+
101+ addToCache : function ( )
102+ {
103+ this . cache . addImage ( this . key , this . data ) ;
104+
105+ this . loader . emit ( 'filecomplete' , this . key , this ) ;
98106 }
99107
100108} ) ;
@@ -131,14 +139,14 @@ FileTypesManager.register('image', function (key, url, xhrSettings)
131139
132140 if ( Array . isArray ( urls ) && urls . length === 2 )
133141 {
134- fileA = this . addFile ( new ImageFile ( key [ i ] , urls [ 0 ] , this . path , xhrSettings ) ) ;
135- fileB = this . addFile ( new ImageFile ( key [ i ] , urls [ 1 ] , this . path , xhrSettings ) ) ;
142+ fileA = this . addFile ( new ImageFile ( this , key [ i ] , urls [ 0 ] , xhrSettings ) ) ;
143+ fileB = this . addFile ( new ImageFile ( this , key [ i ] , urls [ 1 ] , xhrSettings ) ) ;
136144
137145 fileA . setLinkFile ( fileB , 'dataimage' ) ;
138146 }
139147 else
140148 {
141- this . addFile ( new ImageFile ( key [ i ] , url , this . path , xhrSettings ) ) ;
149+ this . addFile ( new ImageFile ( this , key [ i ] , url , xhrSettings ) ) ;
142150 }
143151 }
144152 }
@@ -148,14 +156,14 @@ FileTypesManager.register('image', function (key, url, xhrSettings)
148156
149157 if ( Array . isArray ( urls ) && urls . length === 2 )
150158 {
151- fileA = this . addFile ( new ImageFile ( key , urls [ 0 ] , this . path , xhrSettings ) ) ;
152- fileB = this . addFile ( new ImageFile ( key , urls [ 1 ] , this . path , xhrSettings ) ) ;
159+ fileA = this . addFile ( new ImageFile ( this , key , urls [ 0 ] , xhrSettings ) ) ;
160+ fileB = this . addFile ( new ImageFile ( this , key , urls [ 1 ] , xhrSettings ) ) ;
153161
154162 fileA . setLinkFile ( fileB , 'dataimage' ) ;
155163 }
156164 else
157165 {
158- this . addFile ( new ImageFile ( key , url , this . path , xhrSettings ) ) ;
166+ this . addFile ( new ImageFile ( this , key , url , xhrSettings ) ) ;
159167 }
160168 }
161169
0 commit comments