我对敌人的班级有一个公共变量。As3:从影片剪辑类访问公共变量? (从时间轴和班级中)
如何在访问这个变量,让我们说,主类?还是英雄课?还是任何班级?
我知道你可以访问主类变量与_root。 (在定义之后),但是如何访问外部类值?
ALSO:
如何从时间轴访问特定的影片剪辑,这些外部类值?
下面是代码:
在Worker.as,我有
This part of code is part of a continuous ENTER_FRAME loop..
if(isFlying)
{
if(!faceLeft)
{
gotoAndStop(8);
}
if(faceLeft)
{
gotoAndStop(7);
}
if(flyingDestination < this.x)
{
if(this.x > flyingDestination)
{
this.x -= 3;
}
else
{
isFlying = false;
_root.mainIsFlying = false;
}
}
else
{
if(this.x < flyingDestination)
{
this.x += 3;
}
else
{
isFlying = false;
_root.mainIsFlying = false;
}
}
}
if(_root.isPunching)
{
if(this.hitTestObject(_root.ceo))
{
isFlying = true;
if(this.x < _root.ceo.x)
{
flyToTheLeft();
}
if(this.x > _root.ceo.x)
{
flyToTheRight();
}
}
}
And these are separate functions, a.k.a not part of the ENTER_FRAME function.
private function flyToTheLeft():void
{
flyingDestination = this.x - 100;
faceLeft = true;
}
private function flyToTheRight():void
{
flyingDestination = this.x + 100;
}
在工人影片剪辑的帧8位于飞动漫。在这种飞动漫,我想,这个飞动漫的最后一帧上的代码这样说:
stop();
WORKER.as.isFlying = false;
^^^^^ 我不知道如何代码。
谢谢
我编辑了帖子,并添加了我的代码:) – user3123633