In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Local Union Server Test

localhostのテスト用

ローカルでUnion Serverが起動してないと接続に失敗します

画面クリックでRoomに接続

接続するだけでなにも起きませんが...
Get Adobe Flash player
by moyashi 25 Aug 2010
/**
 * Copyright moyashi ( http://wonderfl.net/user/moyashi )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/25a7
 */

/*
localhostのテスト用

ローカルでUnion Serverが起動してないと接続に失敗します

画面クリックでRoomに接続

接続するだけでなにも起きませんが...

*/


package {
    import flash.text.*
    import flash.display.Sprite;
    import net.user1.reactor.*
    import flash.events.MouseEvent
    public class Union extends Sprite {
        public var reactor:Reactor
        public var _room:Room
        private var txt:TextField
        public function Union(){
            txt=new TextField()
            txt.autoSize=TextFieldAutoSize.LEFT
            txt.text="準備中..."
            addChild(txt)
            
            reactor=new Reactor()
            
            //Frokするなら、ここの"localhost"をお試しサーバーの"tryunion.com"に変更推奨
            reactor.connect("localhost",9100)
            reactor.addEventListener(ReactorEvent.READY,onREADY)
            reactor.addEventListener(ReactorEvent.CLOSE,onCLOSE)
        }
        
        private function onREADY(e:ReactorEvent):void{
            txt.text="接続確認"
            
            _room=reactor.getRoomManager().createRoom("ROOM1")
            _room.addEventListener(RoomEvent.JOIN,onRoomJoin)
            
            stage.addEventListener(MouseEvent.CLICK,onJOIN)
        }
        
        private function onJOIN(e:MouseEvent):void{
            _room.join()
            stage.removeEventListener(MouseEvent.CLICK,onJOIN)
        }

        private function onCLOSE(e:ReactorEvent):void{
            txt.text="接続失敗"
        }
        
        private function onRoomJoin(e:RoomEvent):void{
            txt.text=String(e.target)+"に入室しました"
        }
    }
}