几天来我一直在尝试解决这个问题,但我无法得到什么磨损,我只是在我的“角色”和“糖果”之间添加了 hitTest。在开始工作时,我收到错误 #1009 无法访问空对象引用的属性或方法。在“糖果”第 49 行
“糖果”课
public class Candy extends MovieClip
{
public var leadingMover:Mover;
public var mainColliderCandy:Character;
public var hit:MovieClip;
public var hitParent:*;
public var candy:MovieClip;
public function Candy()
{
addEventListener(Event.ADDED_TO_STAGE, allLoaded);
}
private function allLoaded(event:Event):void
{
hitParent = event.currentTarget.parent;
candy = MovieClip(this.parent.getChildByName(this.name));
hit = hitCandy_mc;
addEventListener(Event.ENTER_FRAME, update);
}
private function update(event:Event):void
{
if(leadingMover)
{
y +=leadingMover.speed;
}
else
{
leadingMover = Mover(parent.getChildByName("bg_mc"));
}
if(mainColliderCandy && candy)
{
if(hit.hitTestObject(mainColliderCandy))
{
//mainColliderCandy.collidedWithCandy(this);
if(candy)
{
//mainColliderCandy = null;
this.parent.removeChild(candy);
}
removeEventListener(Event.ENTER_FRAME, update);
}
}
else
{
mainColliderCandy = Character(parent.getChildByName("character_mc"));
}
}
}
}
谢谢你!