Red5を導入してみる - 1. サーバに接続
FMSのデベロッパー版を導入していじってみたいのにMac版はない...!?
と思って色々探していたら,Macでも利用できる"Red5"というオープンソースFlashサーバを発見.
今回はとりあえず接続できるかテスト.
(要Red5インストール)
Red5:http://osflash.org/red5
参考URL:http://thinkit.co.jp/article/152/3
♥1 |
Line 40 |
Modified 2010-11-24 01:45:55 |
MIT License
archived:2017-03-10 21:55:56
ActionScript3 source code
/**
* Copyright geko ( http://wonderfl.net/user/geko )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zvfV
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.Event;
import flash.events.NetStatusEvent;
public class FlashTest extends Sprite {
public var txt:TextField;
public var server:Red5;
public function FlashTest() {
txt = addChild(new TextField()) as TextField;
txt.width = stage.stageWidth;
txt.height = stage.stageHeight;
server = new Red5();
server.connect("rtmp://localhost/test");
server.addEventListener(NetStatusEvent.NET_STATUS, function netStatus(event:NetStatusEvent):void{
trace(event.info.code);
});
}
public function trace(...str):void{
txt.appendText("\n");
txt.appendText(str.toString());
txt.scrollV = txt.maxScrollV;
}
}
}
import flash.events.EventDispatcher;
import flash.events.NetStatusEvent;
import flash.net.NetConnection;
class Red5 extends EventDispatcher{
public var nc:NetConnection;
public function Red5():void{
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, function _dispatchEvent(event:NetStatusEvent):void{
dispatchEvent(event);
});
}
public function connect(serverURL:String):void{
nc.connect(serverURL);
}
}