Re: [問題] 求救~程式的組件BUG~

看板Flash作者 (無趣的人事物)時間16年前 (2009/10/25 08:44), 編輯推噓1(102)
留言3則, 1人參與, 最新討論串2/3 (看更多)
我改寫成這樣之後 function pressSpace(event) { if (event.keyCode==229) { event.keyCode=32; } if (event.keyCode==32) { textTimer.stop(); play(); /*====================移除偵聽及元件====================*/ textTimer.removeEventListener(TimerEvent.TIMER,setText); stage.removeEventListener(KeyboardEvent.KEY_DOWN,pressSpace); /*======================================================*/ } } stage.addEventListener(KeyboardEvent.KEY_DOWN,pressSpace); 在Flash中執行時,一樣會出現下面的錯誤訊息 TypeError: Error #2007: 參數 child 不能是 Null。 at flash.display::DisplayObjectContainer/addChildAt() at fl.controls::BaseButton/fl.controls:BaseButton::drawBackground() at fl.controls::LabelButton/fl.controls:LabelButton::draw() at fl.controls::Button/fl.controls:Button::draw() at fl.core::UIComponent/::callLaterDispatcher() 也就是組件的部份,又造成的一些狀況~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.227.189.242

10/25 11:03, , 1F
搞不好是組件自己的bug
10/25 11:03, 1F

10/25 11:03, , 2F
用try...catch把Error吃掉,看看程式是否可以正常執行
10/25 11:03, 2F

10/25 11:04, , 3F
有些組件的Error直接把它用try...catch吃掉是沒事的
10/25 11:04, 3F
文章代碼(AID): #1Auvzmwq (Flash)
文章代碼(AID): #1Auvzmwq (Flash)