当我的一个影片剪辑的定位与另一个影片剪辑的定位相同时,我需要发生一些事情。这是我试图使用但不起作用的代码。说“赋值运算符的左侧必须是变量或属性。”。
public class PacketHandler implements PcapPacketHandler<Object> {
@Override
public void nextPacket(PcapPacket packet, Object unused) {
StringBuilder str = new StringBuilder();
packet.getUTF8String(0, str, packet.getTotalSize());
String rawStringData = str.toString();
System.out.println(rawStringData);
String packetAsHex = packet.toHexdump(0, false, true, true);
System.out.println(packetAsHex);
}
}
答案 0 :(得分:1)
希望现在还为时不晚 我认为你的问题在这里:
this._x = this._x + speed;
this._x = this._x - speed;
this._y = this._y + speed;
this._y = this._y - speed;
您应该使用2 var来更改_x和_y 试试这个:
instructions_txt.text = "Pomozite Macku da dodje do cigara!";
var speed:Number = 3;
var pozx;
var pozy;
var baseX = this._x;
var baseY = this._y;
balloon_mc.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
this._x = baseX + speed;
baseX = baseX + speed;
} else if (Key.isDown(Key.LEFT)) {
this._x = baseX - speed;
baseX = baseX - speed;
} else if (Key.isDown(Key.DOWN)) {
this._y = baseY + speed;
baseY = baseY + speed;
} else if (Key.isDown(Key.UP)) {
this._y = baseY - speed;
baseY = baseY - speed;
}
if(pozx == this._x && pozy == this._y)
{
}
};
cigare_mc.onEnterFrame = function() {
this._x = pozx;
this._y = pozy;
}
答案 1 :(得分:0)
您收到了该错误,因为在if
声明中,您使用的是assignment operator ( =
)而不是equality ( ==
),因此您可以写信:
if(pozx == this._x && pozy == this._y) {
// ...
}
有关ActionScript 2的语法和基础知识的更多信息,请查看here。
但是,由于您是初学者,您可以启动learning ActionScript 3(例如,您可以使用AIR来创建一些移动应用...)而不是旧版ActionScript 2 ...
希望可以提供帮助。