作者hhy423 (小天)
看板Flash
标题[问题] 多增加页面常会发生的问题
时间Wed Apr 21 02:57:47 2010
就小弟最近做学校的作业,每次想要多丰富点就会想要多增加点页面~。
但每次只要一增加页面之後,都会出现"无法存取的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
1F:推 cjcat2266:没有完整原始档,不太容易判断null的发生点 04/21 03:12
3F:推 emily114005:将next2_btn注册监听的方法移动到第二个影格,next3_b 04/21 16:53
4F:→ emily114005:tn到第三个影格...以此类推 04/21 16:54
5F:→ emily114005:因为执行时只能抓到当前影格的实体名称 04/21 16:55