有關addEventListener 的使用問題

4 views
Skip to first unread message

janet e

unread,
Feb 1, 2010, 1:10:35 PM2/1/10
to 台灣 Adobe 使用者俱樂部
我寫了兩個classes, 但其中一個class 並不能運行/ 偵測不到event, 我寫的code如下:

package LoginFunctions.UI{
import flash.display.*;
import flash.events.*;

public class CheckStudentInfo extends Sprite {

private var studentInformation: StudentInformation;
private var dataSet:Array;


public function CheckStudentInfo():void {
studentInformation = new StudentInformation("studentInformation");
studentInformation.addEventListener("DATALOADED",
loadStudentRecord);
addChild(studentInformation);

}
private function loadStudentRecord(event:Event):void {
trace("DATALOADING");
dataSet = studentInformation.retrieveData();
trace("DATACOMPLETE");
}

}
}

package LoginFunctions.UI{
import flash.net.*;
import flash.events.*;
import flash.display.*;

public class StudentInformation extends Sprite {
public function StudentInformation
(passURL:String) {
setData();
}
public function setData():void {

dispatchEvent(new Event("DATALOADED"));
}
}

當我run Class CheckStudentInfo 時, "DATALOADING" 和 "DATACOMPLETE" 都不能
output, 請問您們知道是什麼原因嗎?

Ben Chang

unread,
Feb 1, 2010, 3:54:12 PM2/1/10
to au...@googlegroups.com
StudentInformation 建構時,就會執行 setData(),就會送出事件,

這個時間點 (StudentInformation 建構時),尚未 addEventListener,

所以建構完成後的 addEventListener 等於是慢一步





--
您收到此郵件,是因為您訂閱了 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 4, 2010, 1:23:38 PM2/4/10
to 台灣 Adobe 使用者俱樂部
謝謝您, 問題已解決了^^

On 2月2日, 上午4時54分, Ben Chang <ben.rb.ch...@gmail.com> wrote:
> StudentInformation 建構時,就會執行 setData(),就會送出事件,
>
> 這個時間點 (StudentInformation 建構時),尚未 addEventListener,
>
> 所以建構完成後的 addEventListener 等於是慢一步
>

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

Reply all
Reply to author
Forward
0 new messages