1,在使用协议向后台交互时,有时所要用到的协议是需要传入参数的,如已经获得的数据,
下面的方法时定义在PrisonView文件中的,而PrisonItem是PrisonView里的单个条目
private this._currentSelect:view.PrisonItem; //单个条目
private clickFree(evt:egret.TouchEvent) {
if(!this._currentSelect)
{
return;
}
var data:model.PrisonHeroInfo = this._currentSelect.data as model.PrisonHeroInfo; //先拿到数据,this._currentSelect.data中的data其实是调用PrisonItem中的set data方法,从而来获取数据
var command: Net.HeroCommand = <any>new Net.HeroCommand(data.heroUid,data.heroId.toString() ,Net.HeroCommand.FREE_HERO, null);
command["send"]();
}
private clickKill(evt:egret.TouchEvent) {
var data:model.PrisonHeroInfo = this._currentSelect.data as model.PrisonHeroInfo;
var command: Net.HeroCommand = <any>new Net.HeroCommand(data.heroUid,data.heroId.toString() ,Net.HeroCommand.KILL_HERO, null);
command["send"]();
}