var _local6:Command;
if (_arg1){
if ((_arg1 is Class)){
_local6 = (new (_arg1)() as Command);
} else {
_local6 = (_arg1 as Command);
};
_local6.body = _arg2;
this._listeners[_local6] = {};
if (_arg3 != null){
this._listeners[_local6].complete = _arg3;
_local6.addEventListener(CommandEvent.COMPLETE, _arg3, false, _arg5, true);
};
if (_arg4 != null){
this._listeners[_local6].error = _arg4;
_local6.addEventListener(CommandEvent.ERROR, _arg4, false, _arg5, true);
};
};
_local6.addEventListener(CommandEvent.COMPLETE, this.handleCommandEvents, false, _arg5, true);
_local6.addEventListener(CommandEvent.ERROR, this.handleCommandEvents, false, _arg5, true);
_local6.execute();
}
public function harvest(_arg1:int):void{
var onSuccess:* = null;
var onFailed:* = null;
var index:* = _arg1;
onSuccess = function (_arg1:QFAEvent):void{
var _local6:int;
var _local7:*;
_requesting = false;
var _local2:String = (_arg1.data as String);
if ((((_local2 == null)) || ((_local2 == "")))){
return;
};
var _local3:Object = JSON.decode(_local2);
var _local4:DataEvent;
if ((((_local3 == null)) || ((_local3["code"] == 0)))){
_local4 = new DataEvent(EVENT_HARVEST_ERROR);
if (_local3["farmlandIndex"] != undefined){
_local4.data = _local3["farmlandIndex"].toString();
};
dispatchEvent(_local4);
return;
};
if (_local3["status"] != undefined){
_local6 = (_local3["farmlandIndex"] as int);
if ((((_local6 < 0)) || ((_local6 >= _farmJson["farmlandStatus"]["length"])))){
return;
};
_local7 = _farmJson["farmlandStatus"][_local6];
updateLandStatus(_local7, _local3["status"]);
_local4 = new DataEvent(EVENT_HARVEST);
_local4.data = ((_local6.toString() + ",") + _local3["harvest"].toString());
dispatchEvent(_local4);
};
var _local5:Object = (_farmJson["user"] as Object);
if (_local3["money"] != undefined){
_local5["money"] = (_local5["money"] + _local3["money"]);
};
if (_local3["exp"] != undefined){
_local5["exp"] = (_local5["exp"] + _local3["exp"]);
};
};
onFailed = function (_arg1:QFAEvent):void{
_requesting = false;
};
if ((((index < 0)) || ((index >= 24)))){
return;
};
if ((((this._farmJson == null)) || ((this._requesting == true)))){
return;
};
var me:* = (this._farmJson["user"] as Object);
if (me == null){
return;
};
var harvest:* = new CmdHttpRequest();
var postValue:* = {
ownerId:me["uId"],
place:index,
tName:me["userName"],
fName:me["userName"]
};
var url:* = "";
var st:* = Settings.getInstance();
var mode:* = st.mode;
if (mode == "qplus"){
mode = "qzone";
};
var version:* = mode;
if (version == "qzone"){
version = "qzone.qq";
} else {
if (version == "xiaoyou"){
version = st.xymode;
};
};
url = (("http://nc." + version) + ".com/cgi-bin/cgi_farm_plant?mod=farmlandstatus&act=harvest");
url = QzoneJSAPI.addGToken(url);
CommandManager.getInstance().run(harvest, {
url:url,
method:"post",
params:postValue,
complete:onSuccess,
error:onFailed
});
this._requesting = true;