FLASH网游通过XMLSocket与VB后台通信-Flash教程

来源: 作者: 更新时间:2008-03-04 点击:
前段时间用Flash做了个网游的Demo,通讯用的是Socket。曾承诺写个教程,现在有空就把它写写吧。
先从FLASH说起。我要达到的效果是点击地面,人物就走到点击的地点。思路:一个鼠标监听器监听鼠标的点击事件,把X座标和Y座标传到角色,做为角色的目的地。角色每一帧都向这个目的地移动一点点。
role_mc为场景里的一个MovieClip
role_mc.x = role_mc._x;
role_mc.y = role_mc._y;
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
moveRole(role_mc, _xmouse, _ymouse);
};
Mouse.addListener(mouseListener);
function moveRole(role:MovieClip, x:Number, y:Number) {
role.x = x;
role.y = y;
role.onEnterFrame = function() {
if (this.x != this._x) {
this._x = this.x-this._x>0 ? 1 : -1;
}
if (this.y != this._y) {
this._y = this.y-this._y>0 ? 1 : -1;
}
if (this.x == this._x && this.y == this._y) {
delete this.onEnterFrame;
}
};
}
相关Flash教程:
最新评论:
loading.. 评论加载中....
发表评论:不能超过250字节,请自觉遵守互联网相关政策法规.
  • 昵称: 验证:

最新Flash教程