TypeError: Error #1009: 无法访问空对象引用的属性或方法
actionscript吧
全部回复
仅看楼主
level 1
轻舞小钰 楼主
TypeError: Error #1009: 无法访问空对象引用的属性或方法。
at _fla::MainTimeline/frame2()
at flash.display::MovieClip/gotoAndStop()
at _fla::MainTimeline/startHandler()
我想做一个点击在影片剪辑内跳帧 点击次数超过三为失败 三次以内抽到幸运数字为成功可是总是提示这个错误 不知道是为什么 代码如下
import flash.events.MouseEvent;
import flash.display.MovieClip;
stop();
var i:int=0;
do
{
var mc:MC=new MC();
this.addChild(mc);
mc.x=(i%6)*mc.width;
mc.y=int(i/6)*mc.height;
mc.name=String(i);
mc.gotoAndStop(1);
mc.addEventListener(MouseEvent.CLICK,clickHandler);
i++;
}while(i<12);
var luckNumber:int=Math.floor(Math.random()*12);
trace(luckNumber);
var count:int=0;
function clickHandler(e:MouseEvent):void
{
count++;
if(count<=3)//单击次数小于三
{
var mc:MovieClip=(MovieClip)(e.target);
if(int(mc.name)==luckNumber)
{
mc.gotoAndPlay(3);
}
else
{
mc.gotoAndStop(2);
mc.mouseEnabled=false;
}
}
else
{
gotoAndStop("gameOver");
}
}
for(var k:uint=0;k<12;k++)
{
this.removeChild(this.getChildByName(String(k)));
}
success_txt.text="你成功了!";
successRestart_btn.addEventListener(MouseEvent.CLICK,successRestartHandler);
function successRestartHandler(e:MouseEvent):void
{
gotoAndStop("gameStart");
}
for(var j:uint=0;j<12;j++)
{
this.removeChild(this.getChildByName(String(j)));
}
failRestart_btn.addEventListener(MouseEvent.CLICK,failRestartHandler);
function failRestartHandler(e:MouseEvent):void
{
gotoAndStop("gameStart");
}
2015年11月15日 01点11分 1
level 11
trace执行了吗
2015年11月17日 02点11分 2
1