看板 Flash 關於我們 聯絡資訊
就小弟最近做學校的作業,每次想要多豐富點就會想要多增加點頁面~。 但每次只要一增加頁面之後,都會出現"無法存取的null物件參考屬性..." 有時將一段程式碼調往前就解決,有時又不行。 最後常常都是將多增加的內容刪掉= = 請問我犯了什麼樣的錯誤? 以下附一段我寫的程式碼,麻煩指錯~。 stop(); var my_array:Array = new Array(); male_rb.addEventListener(MouseEvent.CLICK,selectedgender); female_rb.addEventListener(MouseEvent.CLICK,selectedgender); function selectedgender(event:MouseEvent):void { my_array[3]=event.target.value; } start_btn.addEventListener(MouseEvent.CLICK,next1); function next1(event:MouseEvent):void { my_array[0]=this.a_txt.text; my_array[1]=this.b_txt.text; my_array[2]=this.c_txt.text; gotoAndStop("1") } next2_btn.addEventListener(MouseEvent.CLICK,next2); function next2(event:MouseEvent):void { my_array[4]=this.cb1_1.selected; my_array[5]=this.cb1_2.selected; my_array[6]=this.cb1_3.selected; my_array[7]=this.cb1_4.selected; my_array[8]=this.cb1_5.selected; my_array[9]=this.cb1_6.selected; my_array[10]=this.cb1_7.selected; my_array[11]=this.cb1_8.selected; trace(my_array[0]); trace(my_array[1]); trace(my_array[2]); trace(my_array[3]); trace(my_array[4]); trace(my_array[6]); trace(my_array[7]); trace(my_array[8]); trace(my_array[9]); trace(my_array[10]); trace(my_array[11]); gotoAndStop("4"); } -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.122.166.136
cjcat2266:沒有完整原始檔,不太容易判斷null的發生點 04/21 03:12
hhy423:http://0rz.tw/iA7Eb 04/21 03:19
emily114005:將next2_btn註冊監聽的方法移動到第二個影格,next3_b 04/21 16:53
emily114005:tn到第三個影格...以此類推 04/21 16:54
emily114005:因為執行時只能抓到當前影格的實體名稱 04/21 16:55