Index: /CKEditor/branches/prototype/_source/core/resourcemanager.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/resourcemanager.js	(revision 2153)
+++ /CKEditor/branches/prototype/_source/core/resourcemanager.js	(revision 2154)
@@ -52,4 +52,31 @@
 
 	/**
+	 * Contains references to all resources that have already been registered
+	 * with {@link #add}.
+	 * @name CKEDITOR.resourceManager.prototype.registered
+	 * @type Object
+	 * @example
+	 */
+	this.registered = {};
+
+	/**
+	 * Contains references to all resources that have already been loaded
+	 * with {@link #load}.
+	 * @name CKEDITOR.resourceManager.prototype.loaded
+	 * @type Object
+	 * @example
+	 */
+	this.loaded = {};
+
+	/**
+	 * Contains references to all resources that have already been registered
+	 * with {@link #addExternal}.
+	 * @name CKEDITOR.resourceManager.prototype.externals
+	 * @type Object
+	 * @example
+	 */
+	this.externals = {};
+
+	/**
 	 * @private
 	 */
@@ -63,28 +90,4 @@
 CKEDITOR.resourceManager.prototype =
 {
-	/**
-	 * Contains references to all resources that have already been registered
-	 * with {@link #add}.
-	 * @type Object
-	 * @example
-	 */
-	registered : {},
-
-	/**
-	 * Contains references to all resources that have already been loaded
-	 * with {@link #load}.
-	 * @type Object
-	 * @example
-	 */
-	loaded : {},
-
-	/**
-	 * Contains references to all resources that have already been registered
-	 * with {@link #addExternal}.
-	 * @type Object
-	 * @example
-	 */
-	externals : {},
-
 	/**
 	 * Registers a resource.
@@ -205,19 +208,25 @@
 					var path = this.externals[ name ] || ( this.basePath + name + '/' );
 
-					// Load the plugin script.
-					CKEDITOR.scriptLoader.load( path + this.fileName + '.js', function( success )
-						{
-							if ( !success )
-								throw '[CKEDITOR.resourceManager.load] Resource name "' + name + '" was not found at "' + path + this.fileName + '.js".';
-
-							loaded[ name ] = path;
-
-							// Check all callbacks that were waiting for this
-							// resource.
-							for ( var j = 0 ; j < waitingInfo.length ; j++ )
-								loadCheck( waitingInfo[ j ] );
-
-							delete waitingList[ name ];
-						});
+					// Putting it in a closure to avoid the variables used
+					// inside the CKEDITOR.scriptLoader.load closure to be
+					// changed in the loop.
+					(function( name, path, fileName )
+					{
+						// Load the plugin script.
+						CKEDITOR.scriptLoader.load( path + fileName + '.js', function( success )
+							{
+								if ( !success )
+									throw '[CKEDITOR.resourceManager.load] Resource name "' + name + '" was not found at "' + path + fileName + '.js".';
+
+								loaded[ name ] = path;
+
+								// Check all callbacks that were waiting for this
+								// resource.
+								for ( var j = 0 ; j < waitingInfo.length ; j++ )
+									loadCheck( waitingInfo[ j ] );
+
+								delete waitingList[ name ];
+							});
+					})( name, path, this.fileName );
 				}
 			}
