請教一個AtionScript 1.0的問題

1 view
Skip to first unread message

Hoskie

unread,
Feb 10, 2010, 11:30:53 AM2/10/10
to 台灣 Adobe 使用者俱樂部
請問下面的程式 this.o.fun()要如何才能正確顯示this.a的值? 謝謝

function A()
{
this.i = 10;
this.s = "aa";
this.o = new Object();
this.test();
}

A.prototype.test = function()
{
trace("this.s: " + this.s); // 顯示 aa
this.o.fun = function()
{
trace("this.s: " + this.s); // 顯示 undefined
}
this.o.fun();
}

Ben Chang

unread,
Feb 10, 2010, 6:49:12 PM2/10/10
to au...@googlegroups.com
function A()
{
       this.i = 10;
       this.s = "aa";
       this.o = new Object();
  this.o["owner"] = this; // 記錄 owner
       this.test();
}

A.prototype.test = function()
{
       trace("this.s: " + this.s);  // 顯示 aa
       this.o.fun = function()
       {
trace(this["owner"].s); //透過 owner 去取得資料
           trace("this.s: " + this.s);
       }
       this.o.fun();
}

var a = new A();




--
您收到此郵件,是因為您訂閱了 Google 網上論壇的「台灣 Adobe 使用者俱樂部 」群組。
如要在此群組張貼留言,請寄電子郵件至 au...@googlegroups.com
如要取消訂閱此群組,請寄電子郵件至 augtw-un...@googlegroups.com
如需更多選項,請造訪此群
組:http://groups.google.com.tw/group/augtw?hl=zh-TW?hl=zh-TW

Hoskie

unread,
Feb 11, 2010, 12:48:42 AM2/11/10
to au...@googlegroups.com
非常感謝,問題已解決。


Sent from Kao-Hsiung, Khh, Taiwan

Reply all
Reply to author
Forward
0 new messages