50 lines
1.3 KiB
ActionScript
50 lines
1.3 KiB
ActionScript
package net.pixvi.myr.net
|
|
{
|
|
import net.pixvi.common.utils.Alert;
|
|
import net.pixvi.common.utils.mobi.MobiTools;
|
|
import net.pixvi.pfw.utils.core.Singleton;
|
|
|
|
public class NetExchange
|
|
{
|
|
|
|
public static const EXCHANGE:String = "itemService/itemExchange";
|
|
|
|
private var onExchangeItemComplete:Function;
|
|
|
|
public function NetExchange()
|
|
{
|
|
super();
|
|
}
|
|
|
|
public static function getIns() : NetExchange
|
|
{
|
|
return Singleton.getInstanceOrCreate(NetExchange) as NetExchange;
|
|
}
|
|
|
|
public function exchangeItem(exchangeId:String, num:int, onComplete:Function) : void
|
|
{
|
|
onExchangeItemComplete = onComplete;
|
|
if(num < 1 || num > 1000)
|
|
{
|
|
Alert.yes("非法","特殊的非法操作。",MobiTools.getIns().exit);
|
|
return;
|
|
}
|
|
var para:Object = {
|
|
"exchangeId":exchangeId,
|
|
"exchangeNum":num
|
|
};
|
|
NetCenter.getIns().send("itemService/itemExchange",para,exchangeItemHandler);
|
|
}
|
|
|
|
private function exchangeItemHandler(re:Object) : void
|
|
{
|
|
if(onExchangeItemComplete != null)
|
|
{
|
|
onExchangeItemComplete(re.reward);
|
|
onExchangeItemComplete = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|