I found the problem. It's not caused by class array actually. The following code demonstrate what I was trying to do:
var A = Class.create(...); var B = Class.create(...); Object.extend(B, { A_ext: Class.create(A, {...}), A_list: { A1: Class.create(B.A_ext, {...}), A2: Class.create(B.A_ext, {...}) } }); The problem of above code is that when it try to reference B.A_ext, which has not been initialized yet. And splitting the "Object.extend(B" to 2 extend actions solves the problem: Object.extend(B, {A_ext: Class.create(A, {...}}); // now that B.A_ext has been initialized, we can use it safely Object.extend(B, { A_list: { A1: Class.create(B.A_ext, {...}), A2: Class.create(B.A_ext, {...}) } }); On Thu, May 27, 2010 at 11:07 AM, green <greenlaw...@gmail.com> wrote: > Hi group > > I tried to store a list of "Class" and fetch those class definition to > create new instance in the following way: > > myclasses = { > A: Class.create({...}), > B: Class.create({...} > ... > }; > ... > for (var i = 0; i < myclasses.length; ++i) { > var cls = myclasses[i]; > var obj = new cls(...); > } > > Unfortunately the above code failed at "var obj = new cls(...);" and it > throws out the exception: "string is not a function". Do you have any idea? > > Thx, > Green > > -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.