【发布时间】:2014-03-01 20:50:27
【问题描述】:
我有一个敌人类的公共变量。
我如何在主类中访问这个变量?还是英雄班?还是什么课?
我知道您可以使用 _root 访问主类变量。 (定义后),但是如何访问外部类值?
还有:
如何从特定影片剪辑的 TIMELINE 访问这些外部类值?
代码如下:
在 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;
^^^^^ 我不知道如何编码。
谢谢
【问题讨论】:
标签: actionscript-3 class variables public var