I've tried that technique before, but I can't get it to work in my situation. If you notice, MyClass is returning data to abc (i.e. var abc = new MyClass). Note the last statement in MyClass (return c). In your example, it doesn't return c.
For example, one of the include files declares a function that is called from MyClass. Therefore, I have to wait for the readyState to be complete before I call the function. Then I can return c.
Assume that the a function getSomething is located in one of the include files that is begining created dynamically. The Code would have to look something like this:
var jQueryScript = document.createElement('script');
jQueryScript.src = 'assets/js/jquery-1.3.1.js';
c.gotSomething = getSomething
As you can see, the line following attachCode() would be exectuted immediately after attachCode ran once. Of cource attachCode would continue to run until the condition was true, but the line of code "c.getSomething" will have already errored by then.
So my question is, how to I prevent attachCode from returning until the conditions are met?