Disable button until image loaded

I’ve been trying to figure out a way to disable buttons until its corresponding image has been loaded. The buttons are created when the xml is loaded. There is a simple onEnterFrame that checks the bytes loaded with the bytes total of the images. When the bytes equal the total then a movieclip with the image is attached. The “id” of that movieclip is assigned to a variable called “loaded”. So, I thought what I could do was check to see if “loaded” equaled the button with the same number then that button would enable and if not, then that button would remain disabled.

This is what I was trying out:

ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#000000]**function**[/COLOR] checkBtn[COLOR=#000000]([/COLOR]butCheck[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]for[/COLOR][COLOR=#000000]([/COLOR]i=[COLOR=#000080]0[/COLOR]; i<imageTotal; i++[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
    [COLOR=#0000FF]if[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]loaded[/COLOR] == butCheck[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
        butCheck.[COLOR=#0000FF]enabled[/COLOR] = [COLOR=#000000]**true**[/COLOR];
    [COLOR=#000000]}[/COLOR][COLOR=#0000FF]else[/COLOR][COLOR=#000000]{[/COLOR]
        butCheck.[COLOR=#0000FF]enabled[/COLOR] = [COLOR=#000000]**false**[/COLOR];
    [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

[COLOR=#000000]}[/COLOR]
[/LEFT]
[/FONT]

I was just wondering if someone could give me an example or their thoughts on how this might be done?

Thanks for the help.