Quick answer: GameMaker async load callbacks arriving out of order? Match async_load[? “id”] against the original request ID — the engine doesn’t serialize completions.
Three sprites are loaded asynchronously and the third loads before the first. Code assuming sequential order tries to apply sprite A’s data to sprite B.
Match by Request ID
Every async request returns an ID. The async event’s async_load[? “id”] tells you which request completed. Index your pending data by that ID, not by call order.
Use a ds_map for Pending
pending[? request_id] = { sprite: target_sprite };
// in async event:
var entry = pending[? async_load[? "id"]];
Status Codes
Check async_load[? “status”] before applying — non-zero status means failure. Treating failures as success creates harder-to-diagnose bugs later.
Verifying
Run with three concurrent loads in randomized completion order — each loads to its right target. No mix-ups.
“Async callbacks return in completion order, not call order. Match by ID.”
Wrap async I/O in a tiny helper that returns a future-like object — gameplay code awaits the future, doesn’t touch async_load directly.