關於addChild 的問題

2 views
Skip to first unread message

janet e

unread,
Feb 9, 2010, 2:43:39 PM2/9/10
to 台灣 Adobe 使用者俱樂部
我想把addChild 放置於另一個class中, 以下是這兩個classes:

public class ClassA extends Sprite {
private var loginSystem: LoginSystem=new LoginSystem;
public function ClassA():void {
loginSystem.addLoginPage(loginIDLabel);

}
}


public class LoginSystem extends Sprite {

public function LoginSystem():void {
}
public function addLoginPage(loginIDLabel:DisplayObject) {
parent.addChild(loginIDLabel);
}
}

但loginIDLabel 並沒有顯示出來, 而且出現"Error #1009: 無法存取 Null 物件參考的屬性或方法。" . 請問是否不
能在另一class中addChild ?

Ben Chang

unread,
Feb 9, 2010, 6:21:08 PM2/9/10
to au...@googlegroups.com
在 ClassA 中,你只是定義了一個 LoginSystem 類別的物件,但是沒將他加進任何 DisplayObjectContainer 中,

所以對 loginSystem 來說,他還沒有 parent 的存在~




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

janet e

unread,
Feb 10, 2010, 3:28:41 AM2/10/10
to 台灣 Adobe 使用者俱樂部
謝謝!

On 2月10日, 上午7時21分, Ben Chang <ben.rb.ch...@gmail.com> wrote:
> 在 ClassA 中,你只是定義了一個 LoginSystem 類別的物件,但是沒將他加進任何 DisplayObjectContainer 中,
>
> 所以對 loginSystem 來說,他還沒有 parent 的存在~
>

> janet e <janet...@gmail.com> 於 2010年2月10日上午3:43 寫道:
>
>
>
> > 我想把addChild 放置於另一個class中, 以下是這兩個classes:
>
> > public class ClassA extends Sprite {
> > private var loginSystem: LoginSystem=new LoginSystem;
> > public function ClassA():void {
> > loginSystem.addLoginPage(loginIDLabel);
>
> > }
> > }
>
> > public class LoginSystem extends Sprite {
>
> > public function LoginSystem():void {
> > }
> > public function addLoginPage(loginIDLabel:DisplayObject) {
> > parent.addChild(loginIDLabel);
> > }
> > }
>
> > 但loginIDLabel 並沒有顯示出來, 而且出現"Error #1009: 無法存取 Null 物件參考的屬性或方法。" . 請問是否不
> > 能在另一class中addChild ?
>
> > --
> > 您收到此郵件,是因為您訂閱了 Google 網上論壇的「台灣 Adobe 使用者俱樂部 」群組。
> > 如要在此群組張貼留言,請寄電子郵件至 au...@googlegroups.com
> > 如要取消訂閱此群組,請寄電子郵件至 augtw-un...@googlegroups.com
> > 如需更多選項,請造訪此群

> > 組:http://groups.google.com.tw/group/augtw?hl=zh-TW?hl=zh-TW。- 隱藏被引用文字 -
>
> - 顯示被引用文字 -

Reply all
Reply to author
Forward
0 new messages