extjs定义一个类,在类中加入成员变量出现错误

RegisterWindow=Ext.extend(Ext.Window,{
formPanel:new RegisterFormPanel(),
constructor:function(_config){
_config=Ext.apply({
title:"注册窗口",
width:400,
items:[this.formPanel]
},_config);
RegisterWindow.superclass.constructor.call(this,_config);
}
});
/************************************************************************************/
RegisterFormPanel=Ext.extend(Ext.form.FormPanel,{
constructor:function(_config){
_config=Ext.apply({
labelWidth:75,
defaults:{
xtype:"textfield",
anchor:"98%"
},
items:[{
fieldLabel:"姓名"
}],
buttons:[{
text:"注册"
},{
text:"重置"
}]
},_config);
RegisterFormPanel.superclass.constructor.call(this,_config);
}
});
上面的代码包含在文件中 调用var _registerWindow = new RegisterWindow().show();出现RegisterWindow未定义怎么回事

js 是顺序执行的。在执行 RegisterWindow=Ext.extend(Ext.Window,{
formPanel:new RegisterFormPanel(), 的时候RegisterFormPanel还没声明

吧他们顺序替换下就行了。

/************************************************************************************/
RegisterFormPanel=Ext.extend(Ext.form.FormPanel,{
constructor:function(_config){
_config=Ext.apply({
labelWidth:75,
defaults:{
xtype:"textfield",
anchor:"98%"
},
items:[{
fieldLabel:"姓名"
}],
buttons:[{
text:"注册"
},{
text:"重置"
}]
},_config);
RegisterFormPanel.superclass.constructor.call(this,_config);
}
});
RegisterWindow=Ext.extend(Ext.Window,{
formPanel:new RegisterFormPanel(),
constructor:function(_config){
_config=Ext.apply({
title:"注册窗口",
width:400,
items:[this.formPanel]
},_config);
RegisterWindow.superclass.constructor.call(this,_config);
}
});