Connecting to Flash Media Server Using ActionScript 3.0
A lot of times you will need to connect to Flash Media Server , where there is lot of code avialable for AS 2.0 , I was not able to find much code on AS 3.0 . I hope this helps other fellow Action Script programmers out there.
package
{
import flash.net.NetConnection;
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.NetStatusEvent;
public class FMSManager extends Sprite
{
private var nc:NetConnection;
private var rtmpNow:String;
private var msg:String;
private var connectText:TextField;
private var posX:Number;
public function FMSManager ()
{
nc=new NetConnection();
nc.addEventListener (NetStatusEvent.NET_STATUS,checkConnect);
rtmpNow=”rtmp://timfuzos.rtmphost.com/one2oneChat/room1″; //change the host name to your host
//rtmpNow=”rtmpe:/one2oneChat/room1″; // if your FMS is hosted in local use this
nc.connect (rtmpNow,”sumit”);
}
private function checkConnect (event:NetStatusEvent):void
{
connectText=new TextField();
msg=event.info.code;
trace(msg);
connectText.width=250;
connectText.text=msg;
addChild (connectText);
posX=connectText.stage.stageWidth;
connectText.x=(posX/2)-((msg.length/2)*(6));
connectText.y=175;
}
}
}
The screen would look like this
Download code from here.
Popularity: 48% [?]