This event is triggered when you load an image into GameMaker either on HTML5, or through a URL. For example, say you want to load a sprite image, and only change the current sprite for the instance to the new one after it has loaded. You would have something like this in the Create event (or any other event):
var _url = "http://www.angusgames.com/game/background1.png";
spr = sprite_add(_url, 0, false, false, 0, 0);
This will now start to load the image into the device or the browser, but it will not block GameMaker while it waits for the file to be loaded. Instead GameMaker will keep running as normal until the image is loaded and the callback triggers the Image Loaded Event, where a DS Map is created and stored in the special variable async_load. The map contains the following information:
You would then assign the newly loaded image to a sprite in this event. The following code example demonstrates how the returned information would be used:
if (ds_map_find_value(async_load, "id") == spr)
{
if (ds_map_find_value(async_load, "status") >= 0)
{
sprite_index = spr;
}
}
The above code will first check the id of the DS map that has been created, then check the status of the callback. If the value is greater than or equal to 0 (signalling success) the result from the callback will then be used to set the sprite index to the newly loaded image.