[Wsocket] Socket GUI 클래스






WSocket.swc


Created with colorer-take5 library. Type 'csharp'

package
{
    import WallSocket.SocketEvent.WSocketEvent;
    import WallSocket.SocketEvent.WSocketMRGEvent;
    import WallSocket.WSocket;
    
    import fl.controls.Button;
    
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.MouseEvent;
    
    [SWF(backgroundColor=0x00 , width = 1000 , height = 500)]
    public class testSocketW extends Sprite
    {
        //gui 표시 버튼
        private var call:Button = new Button;
        
        //Wsocket instance
        private var ws:WSocket;
        public function testSocketW()
        {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            
            addChild(call);
            call.x =stage.stageWidth/2 - call.width/2 ; 
            call.y = stage.stageHeight/2 - call.height/2;
            call.label = "call GUI";
            call.addEventListener(MouseEvent.CLICK , GUI_Call);
            
            
            //선언
            ws = WSocket.getWSocket(this);
            
            //이벤트들
            ws.reciveProxy().addEventListener(WSocketEvent.CONNECT , con);
            ws.reciveProxy().addEventListener(WSocketEvent.DISCONNECT , con);
            ws.reciveProxy().addEventListener(WSocketMRGEvent.MASSAGE , msg);
            
            //��플 메세지 송신
            stage.addEventListener(MouseEvent.CLICK , sendMsg);
        }
        private function sendMsg(e:MouseEvent):void
        {
            //메세지 송신
            ws.sendProxy("send msg");
        }
        
        private function msg(e:WSocketMRGEvent):void
        {
            //메세지 ��신 (이벤트 arg 활용)
            trace(" massage " , e.mrg);
        }
        
        private function GUI_Call(e:MouseEvent):void
        {
            //gui 표시 메서드
            ws.showGUI();
        }
        
        private function con(e:WSocketEvent):void
        {
            if(e.type == WSocketEvent.CONNECT) trace("connect");
            if(e.type == WSocketEvent.DISCONNECT) trace("disconnect");
        }
    }
}
Yamecoder 야매코더_
AS3 2010.12.04 02:44
Powerd by Tistory, designed by criuce
rss