有人能告诉我为什么会出现此错误吗?AS3- ReferenceError:Error#1069:Property not found
ReferenceError:错误#1069:未在com.usmanzubairi.theAges.TheAges上找到属性roll_mc并且没有默认值。 在com.usmanzubairi.theAges :: PirGame /滚动()
package com.usmanzubairi.theAges
{
import flash.display.MovieClip;
import flash.events.*;
import flash.media.*;
public class TheAges extends MovieClip
{
private var game:PirGame;
private var game2:PreGame;
private var game3:SupGame;
public function TheAges()
{
stage.addEventListener(MouseEvent.CLICK, startGame);
}
private function startGame(event:Event):void
{
if (event.target != player_btn)
{
removeEventListener(MouseEvent.CLICK, startGame);
game = new PirGame();
addChild(game);
}
else
{
addChild(player_mc);
player_mc.visible = true;
player_mc.play();
}
if (event.target == player_mc.tom_mc)
{
removeEventListener(MouseEvent.CLICK, startGame);
game2 = new PreGame();
addChild(game2);
}
if (event.target == player_mc.pete_mc)
{
removeEventListener(MouseEvent.CLICK, startGame);
game = new PirGame();
addChild(game);
}
if(event.target == player_mc.sam_mc)
{
removeEventListener(MouseEvent.CLICK, startGame);
game3 = new SupGame();
addChild(game3);
}
}
public function gameOver():void
{
removeChild(game);
game = null;
stage.addEventListener(MouseEvent.CLICK, startGame);
}
}
}
这里的PirGame文档类代码:
package com.usmanzubairi.theAges
{
import flash.utils.Timer;
import flash.events.*;
import flash.display.*;
import flash.geom.Matrix;
import flash.net.SharedObject;
public class PirGame extends MovieClip
{
public function PirGame()
{
addEventListener(MouseEvent.CLICK,rolling);
}
private function rolling (event:Event):void
{
if (event.target == MovieClip(root).roll_mc)
{
addChild(roll)
roll.visible = true;
runner_mc.visible = false;
roll.play();
}
}
}
}
感谢。
你打算说一些关于“roll”的东西吗?你在roll()函数中使用的roll_mc是什么... –
“roll”是一个滚动动画,“roll_mc”是播放该滚动动画的按钮。 – user3302134
你确定roll_mc存在吗?尝试在你的条件之前测试它以查看值('if(MovieClip(root).roll_mc && event.target == MovieClip(root).roll_mc)')。如果为null,则该对象不存在。尝试调试你的电影(ctrl + maj + enter)而不是运行它(ctrl + enter),你会得到更好的错误信息,你可以看到所有的变量值都是错误时间。 –