document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. var nc:NetConnection;
  2. var ns:NetStream;
  3. var nsPlayer:NetStream;
  4. var vid:Video;
  5. var vidPlayer:Video;
  6. var cam:Camera;
  7. var mic:Microphone;
  8.  
  9. nc = new NetConnection();
  10. nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
  11.  
  12. var username:String = "azrilnazli";
  13. var password:String = "abc123";
  14. nc.connect("rtmp://202.190.99.75/videochat");
  15. //nc.connect("rtmp://10.10.76.201/live");
  16. //nc.connect("rtmp://map.cikgu.net.my/live");
  17.  
  18. function onNetStatus(event:NetStatusEvent):void{
  19.     trace(event.info.code);
  20.     if(event.info.code == "NetConnection.Connect.Success"){
  21.         publishCamera();
  22.         displayPublishingVideo();
  23.         displayPlaybackVideo();
  24.     }
  25. }    
  26.  
  27. function publishCamera() {
  28.     cam = Camera.getCamera();
  29.     mic = Microphone.getMicrophone();
  30.     ns = new NetStream(nc);
  31.     ns.attachCamera(cam);
  32.     ns.attachAudio(mic);
  33.     ns.publish(username, "live");
  34. }
  35.  
  36. function displayPublishingVideo():void {
  37.     vid = new Video();
  38.     vid.x = 5;
  39.     vid.y = 5;
  40.     vid.attachCamera(cam);
  41.     addChild(vid);  
  42. }
  43.  
  44. function displayPlaybackVideo():void{
  45.     nsPlayer = new NetStream(nc);
  46.     nsPlayer.play(username);
  47.     vidPlayer = new Video();
  48.     vidPlayer.x = cam.width + 170;
  49.     vidPlayer.y = 5;
  50.     vidPlayer.attachNetStream(nsPlayer);
  51.     addChild(vidPlayer);
  52. }
');