Tracking events?

I still haven’t found a suitable solution to my problem…

**What I’m trying to do…
**[LIST=1]
[]Load a series of images as Bitmap objects into an Object structure (think associative array/hashmap)
[
]Use said images in some fashion…[/LIST]How I’m trying to do it…
I have (200+) images in a directory named under a common scheme (two character country codes). Using another source of data to extrapolate which images I’ll need (data served via XML), I simply try and load the images as follows:

[FONT=Courier New][COLOR=#000000]var[/COLOR] loader:Loader;
[COLOR=#0000ff]for[/COLOR][COLOR=#000000]([/COLOR] [COLOR=#000000]var[/COLOR] prop:[COLOR=#0000ff]String[/COLOR] [COLOR=#0000ff]in[/COLOR] [COLOR=#0000ff]xml[/COLOR].[COLOR=#000080]item[/COLOR] [COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
loader = [COLOR=#000000]new[/COLOR] LoaderCOLOR=#000000[/COLOR];

loader.[COLOR=#000080]contentLoaderInfo[/COLOR].[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR]Event.[COLOR=#000080]INIT[/COLOR], loaderInitialized[COLOR=#000000])[/COLOR];

   [COLOR=#808080]*// the handler for this event doesn't do anything (it's only ever fired when an image that doesn't exist is requested)*[/COLOR]
   loader.[COLOR=#000080]contentLoaderInfo[/COLOR].[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR]IOErrorEvent.[COLOR=#000080]IO_ERROR[/COLOR], loaderIOError[COLOR=#000000])[/COLOR];
    
loader.[COLOR=#0000ff]load[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]**new**[/COLOR] URLRequest[COLOR=#000000]([/COLOR][COLOR=#808080]*/* an image */*[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR];

[COLOR=#000000]}[/COLOR]

[COLOR=#000000]function[/COLOR] loaderInitialized[COLOR=#000000]([/COLOR] [COLOR=#0000ff]e[/COLOR]:Event [COLOR=#000000])[/COLOR]:[COLOR=#0000ff]void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#000000]var[/COLOR] loader:Loader = [COLOR=#0000ff]e[/COLOR].[COLOR=#0000ff]target[/COLOR].[COLOR=#000080]loader[/COLOR];
[COLOR=#000000]var[/COLOR] key:[COLOR=#0000ff]String[/COLOR] = [COLOR=#0000ff]e[/COLOR].[COLOR=#0000ff]target[/COLOR].[COLOR=#0000ff]url[/COLOR].[COLOR=#0000ff]substring[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]e[/COLOR].[COLOR=#0000ff]target[/COLOR].[COLOR=#0000ff]url[/COLOR].[COLOR=#000080]length[/COLOR]-[COLOR=#000080]6[/COLOR], [COLOR=#0000ff]e[/COLOR].[COLOR=#0000ff]target[/COLOR].[COLOR=#0000ff]url[/COLOR].[COLOR=#000080]length[/COLOR]-[COLOR=#000080]4[/COLOR][COLOR=#000000])[/COLOR];
bitmaps[COLOR=#000000][[/COLOR]key[COLOR=#000000]][/COLOR] = BitmapCOLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR][/FONT]

The problem
I’m running into a race condition with loading the images into my Object (bitmaps) and then using bitmaps elsewhere in my application. The code that’s trying to access the Bitmap objects out of bitmaps is always returning undefined since my loaderInitialized is still being executed.

Is there anything I can do to avoid the race condition? Is my problem clearly explained?

It’s been suggested that I try reducing the 200+ requests to a single one by combing all the images into a single file - but this isn’t ideal as it’s not flexible to adding more data and images.