w1114367261 this.storelist.renderHandler=new Handler(this,onRender);//当list刷新时触发 并发送Box,index
this.storelist.mouseHandler = new Handler(this,onMouse);//当list被点击时触发 并发送event,index
}
public function onRender(cell:Box,index:int):void
{
//当list刷新时接收并更改单元格属性
var hero:Image = cell.getChildByName("hero")as Image;//根据名字查找要更改的单元格
hero.disabled = HostData.array[index].hero;//属性更改
var ani :Animation = cell.getChildByName("heroani") as Animation;//加载默认动画
if (ani){
ani.play(0,true,"standDown"+HostData.array[index].aniname);//控制播放相应角色的动画
}
var own :Text = cell.getChildByName("owntext") as Text;//同步是否已经拥有的text显示状态
if (own){
if(HostData.array[index].lock){
own.visible = false;
}else{
own.visible = true;
}
}
var lock :Button = cell.getChildByName("lock") as Button;
if(lock){
lock.visible = HostData.array[index].lock;//默认角色购买锁定状态赋值
lock.disabled =HostData.array[index].hero;//角色禁用状态赋值
}
var gold:Box = cell.getChildByName("gold")as Box;//金币赋值
if (gold){
if(HostData.array[index].lock){//该角色是不是已经解锁了 如果没解锁进行赋值
var goldlabel:Label = gold.getChildByName("goldLabel")as Label;
goldlabel.text= HostData.array[index].gold;//商城角色购买金额的赋值
}else{
gold.visible =false;//如果已经解锁了 那么关闭金币购买UI
}
}
}
public function onMouse(e:Event,index:int):void{
//判断点击的类型 是否是点击一次
if(e.type=="click")
{
//如果点击的对象是button类型
if(e.target is Button)
{
if(HostData.gold>HostData.array[index].gold){ //我的金币是否满足购买条件
HostEvent.I.event(HostEvent.LICKLOAD,["是否花费"+HostData.array[index].gold+"个金币购买该角色!!",1,index]);//发送解锁事件并发送弹窗提示信息
}else{
HostEvent.I.event(HostEvent.LICKLOAD,["您的金币不足"+HostData.array[index].gold+"个无法购买该角色!!",0]);//发送解锁事件并发送弹窗提示信息
}
}