Home

# Class goog.net.ImageLoader

Image loader utility class. Raises a {@link goog.events.EventType.LOAD} event for each image loaded, with an {@link Image} object as the target of the event, normalized to have {@code naturalHeight} and {@code naturalWidth} attributes.

extends goog.events.EventTarget

Instance Method Summary
| `addImage(string id, (Image|null|string) image)` Adds an image to the image loader, and associates it with the given ID string. If an image with that ID already exists, it is silently replaced. When the image in question is loaded, the target of the LOAD event will be an {@code Image} object with {@code id} and {@code src} attributes based on these arguments.

`disposeInternal()`

Unattach listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners, it should be something like this:

    MyClass.prototype.disposeInternal = function() {
    MyClass.superClass_.disposeInternal.call(this);
    // Dispose logic for MyClass
    };

| `loadImage_(string src, string id)` Creates an {@code Image} object with the specified ID and source URL, and listens for network events raised as the image is loaded.
| `onNetworkEvent_(?goog.events.Event evt)` Handles net events (READY_STATE_CHANGE, LOAD, ABORT, and ERROR).
| `removeImage(string id)` Removes the image associated with the given ID string from the image loader.
| `start()` Starts loading all images in the image loader in parallel. Raises a LOAD event each time an image finishes loading, and a COMPLETE event after all images have finished loading.