View Full Version : Dynamic Extend?

Digital God
10 Sep 2008, 11:49 PM
Hi, i'm trying to extend my classes dynamic.
But i got error "TypeError: Can't get property constructor from undefined value"

What i've:

function compileFunc(fsource){
var Func = Ext.extend(Ext.util.Observable,fsource);
return Func;

and this is how i call function

new (compileFunc(mods[0].source))()

this is source of some module

constructor: function(config) {
// Your preprocessing here
Func.superclass.constructor.apply(this, arguments);
// Your postprocessing here

yourMethod: function() {
// etc.

whats wrong? or i can't extend class from some variable?

10 Sep 2008, 11:53 PM
You should be able to, try this:

var o =
foo: function()
return 'hi!';

var MyClass = Ext.extend(Object, o);
var c = new MyClass();

Digital God
10 Sep 2008, 11:56 PM
in my case - var o is a string... i get module source from Ajax request

11 Sep 2008, 12:30 AM
Well you have to eval it then. You can't extend a string, you extend a function.

Digital God
11 Sep 2008, 12:40 AM
Well you have to eval it then
this is my main problem - i use Adobe AIR...
well, thx :)... will try to find some solution...

11 Sep 2008, 1:09 AM
There must be a way to eval in Air, otherwise, you could not recieve JSON.