as3 Error #1009: 无法访问空对象引用的属性或方法.
as代码:package{importflash.display.MovieClip;importflash.text.TextField;importflash.eve...
as代码:
package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.Event;
public class Textshow extends MovieClip{
private var num:int;
private var _txt:TextField;
public function Textshow() {
_txt = this.getChildByName("txt") as TextField;
}
private function init():void {
num=1000;
_txt.text = String(num);
}
}
}
第一帧动作:import flash.events.MouseEvent;
btnstart.addEventListener(MouseEvent.CLICK,playClick);
function playClick(e:MouseEvent):void{
btnstart.removeEventListener(MouseEvent.CLICK,playClick);
this.gotoAndStop("play");
}
stop();
第二帧动作:
stop();
init();
错误提示:TypeError: Error #1009: 无法访问空对象引用的属性或方法。
at Textshow/init()
at Textshow/frame2()
at flash.display::MovieClip/gotoAndStop()
at Textshow/playClick() 展开
package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.Event;
public class Textshow extends MovieClip{
private var num:int;
private var _txt:TextField;
public function Textshow() {
_txt = this.getChildByName("txt") as TextField;
}
private function init():void {
num=1000;
_txt.text = String(num);
}
}
}
第一帧动作:import flash.events.MouseEvent;
btnstart.addEventListener(MouseEvent.CLICK,playClick);
function playClick(e:MouseEvent):void{
btnstart.removeEventListener(MouseEvent.CLICK,playClick);
this.gotoAndStop("play");
}
stop();
第二帧动作:
stop();
init();
错误提示:TypeError: Error #1009: 无法访问空对象引用的属性或方法。
at Textshow/init()
at Textshow/frame2()
at flash.display::MovieClip/gotoAndStop()
at Textshow/playClick() 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询