📄 hall.as
字号:
package com.junhuanet.chatroom.hall
{
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.text.TextField;
import flash.events.MouseEvent;
import com.junhuanet.chatroom.hall.RoomItem;
import com.junhuanet.chatroom.hall.NewWin;
import com.junhuanet.chatroom.hall.PwdWin;
import com.junhuanet.chatroom.publicsymbol.AlertNobady;
public class Hall extends MovieClip
{
private var room_mc:MovieClip;
private var alert_mc:MovieClip;
private var win_mc:MovieClip;
private var currentPage:Number=1;
private var totalPage:Number=0;
private var perPage:Number=12;
private var room_array:Array=new Array();
public var objTempData:Object=new Object();
public function Hall()
{
initHall();
}
public function showTheRoomList(_array:Array):void
{
room_array=_array;
setPageData(_array);
if(this.getChildByName("room_mc"))
{
this.removeChild(room_mc);
}
room_mc=new MovieClip();
room_mc.name="room_mc";
room_mc.x=22;
room_mc.y=110;
addChild(room_mc);
if(this.getChildByName("win_mc"))
{
swapChildren(win_mc,room_mc);
}
for(var i=0;i<_array.length;i++)
{
var temp_x:Number=i%3*200;
var temp_y:Number=int((i%perPage)/3)*77;
var temp_mc:MovieClip=new RoomItem();
temp_mc.name="item"+i;
temp_mc.x=temp_x;
temp_mc.y=temp_y;
temp_mc.visible=false;
temp_mc.roomname_txt.text=_array[i].name;
temp_mc.nick_txt.text=_array[i].nickName;
temp_mc.num_txt.text=_array[i].online.length+"/4";
temp_mc.id_txt.text=_array[i].roomid;
temp_mc.lock_mc.visible=Boolean(_array[i].lock);
temp_mc.addEventListener(MouseEvent.CLICK,roomitemClick);
room_mc.addChild(temp_mc);
}
showCurrentPage();
}
public function removeWin():void
{
if(this.getChildByName("win_mc"))
{
removeChild(win_mc);
}
}
public function newRoom(room:Object):void
{
var objTemp:Object=this.parent.parent;
objTemp.newRoom(room);
}
//**************************************************
private function initHall():void
{
enter_btn.addEventListener(MouseEvent.CLICK,enterClick);
new_btn.addEventListener(MouseEvent.CLICK,newClick);
search_btn.addEventListener(MouseEvent.CLICK,searchClick);
exit_btn.addEventListener(MouseEvent.CLICK,exitClick);
back_btn.addEventListener(MouseEvent.CLICK,backClick);
next_btn.addEventListener(MouseEvent.CLICK,nextClick);
//var objTemp:Object=this.parent.parent;
//objTemp.refreshList();
}
private function setPageData(_array:Array):void
{
if(_array.length%perPage==0)
{
totalPage=_array.length%perPage;
}
else
{
totalPage=int(_array.length/perPage)+1;
}
if(totalPage==0)
{
totalPage=1;
}
page_txt.text=currentPage+" / "+totalPage;
}
private function showCurrentPage():void
{
for(var i=0;i<room_array.length;i++)
{
if((int(i/perPage)+1)==currentPage)
{
if(this.getChildByName("room_mc"))
{
var ttemp:Object=this.getChildByName("room_mc");
var ttemp2:Object=ttemp.getChildByName("item"+i);
ttemp2.visible=true;
}
}
else
{
if(this.getChildByName("room_mc"))
{
var ftemp:Object=this.getChildByName("room_mc");
var ftemp2:Object=ftemp.getChildByName("item"+i);
ftemp2.visible=false;
}
}
}
}
private function enterClick(event:MouseEvent):void
{
removeWin();
var objTemp:Object=this.parent.parent;
if(objTemp.roomList_array.length>0)
{
objTemp.autoEnterRoom();
}
else
{
win_mc=new AlertNobady();
win_mc.name="win_mc";
win_mc.x=(stage.stageWidth-win_mc.width)/2;
win_mc.y=(stage.stageHeight-win_mc.height)/2;
addChild(win_mc);
}
}
private function newClick(event:MouseEvent):void
{
if(this.getChildByName("win_mc"))
{
removeChild(win_mc);
}
win_mc=new NewWin();
win_mc.name="win_mc";
win_mc.x=(stage.stageWidth-win_mc.width)/2;
win_mc.y=(stage.stageHeight-win_mc.height)/2;
addChild(win_mc);
}
private function searchClick(event:MouseEvent):void
{
}
private function exitClick(event:MouseEvent):void
{
var objTemp:Object=new Object();
objTemp=this.parent.parent;
objTemp.exitHall();
}
private function backClick(event:MouseEvent):void
{
if(currentPage>1)
{
currentPage--;
showCurrentPage();
}
}
private function nextClick(event:MouseEvent):void
{
if(currentPage<totalPage)
{
currentPage++;
showCurrentPage();
}
}
private function roomitemClick(event:MouseEvent):void
{
var objCurrent:Object=event.target;
var objParent:Object=objCurrent.parent;
var n:int=int(objParent.name.substring(4));
var objTemp:Object=this.parent.parent;
if(room_array[n].lock)
{
objTempData.pwd=room_array[n].pwd;
objTempData.roomid=room_array[n].roomid;
showPwdWin();
}
else
{
objTemp.enterMyRoom(room_array[n].roomid);
}
}
private function showPwdWin():void
{
if(this.getChildByName("win_mc"))
{
removeChild(win_mc);
}
win_mc=new PwdWin();
win_mc.name="win_mc";
win_mc.x=(stage.stageWidth-win_mc.width)/2;
win_mc.y=(stage.stageHeight-win_mc.height)/2;
addChild(win_mc);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -