我怎么才能在Toolbox中访问到MapEditer的成员呢?this.editerLeft或者editerLeft 都访问不到哦!怎么解决呢?
--------------------------------------
MapEditer = function()
{
// Editer
var UNIT = 'px ';
this.editerLeft = 100;
this.editerTop = 20;
this.editerWidth = 800;
this.editerHeight = 600;
// Toolbox
var Toolbox = function()
{
// Toolbox
this.toolboxLeft = editerLeft + 10; // 请问这里怎么才能访问到editerLeft阿?
this.toolboxTop = editerTop + 10;
this.toolboxWidth = 150;
this.toolboxHeight = 580;
this.Create = function()
{
}
}
this.Create = function()
{
}
}
帮忙看看,帮顶有分!!谢谢!!
------解决方案--------------------
var Toolbox = function()
->
thi.Toolbox = function()
------解决方案--------------------
对不起,没看清楚,程序感觉关怪的!
Toolbox的context是全局的,要想访问MapEditer,我想只能传参数了
------解决方案--------------------
MapEditer = function()
{
// Editer
var UNIT = 'px ';
var wc = this;
this.editerLeft = 100;
this.editerTop = 20;
this.editerWidth = 800;
this.editerHeight = 600;
// Toolbox
var Toolbox = function()
{
// Toolbox
alert(wc.editerLeft)
你这里的this可是window了。。你给window加这么多属性?
this.toolboxLeft = editerLeft + 10; // 请问这里怎么才能访问到editerLeft阿?
this.toolboxTop = editerTop + 10;
this.toolboxWidth = 150;
this.toolboxHeight = 580;
this.Create = function()
{
}
}
this.Create = function()