Java object with eventhandler overloading
===

Currently im trying to write a resourcemanager in java. It has two methods, one to add a image resource to the manager, and one that preloads all the images after they are added:

    ResourceManager = function(){};
    ResourceManager.prototype = function(){
    
     var imageList = new Array(),
         
         addImage = function(imageUrl){
          imageList.push(imageUrl);
         },
         loadImages = function(){
          //Do stuff for loading here
          onComplete();
         },
         onComplete = function(){
          alert('finished');
         };

         return {
          addImage: addImage,
          loadImages: loadImages,
          onComplete: onComplete
         }
    }();

Then I want to use it as following

    var rsmgr = new ResourceManager();
    rsmgr.onComplete = function(){
     alert('completed');
    };
    rsmgr.addImage('image.png');
    rsmgr.loadImages();

You can see a working example [on jsfiddle][1]

Now this overoad is not working, so why does this happen? I'm guessing it has to do with the prototyping but I can't seem to grasp on how to fix this. 


  [1]: http://jsfiddle.net/