`

shredObject简单例子

    博客分类:
  • flex
阅读更多
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
	<mx:Script>
		<![CDATA[
			
			import flash.net.SharedObject;
			import mx.logging.Log;
			private var net:NetConnection;
			private var soChat:SharedObject;
		
			public function init():void{
				NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;
				SharedObject.defaultObjectEncoding  = flash.net.ObjectEncoding.AMF0;	
				net=new NetConnection();
				net.connect("rtmp://192.168.200.14/red");//我用的是red5,/ red是我的一个随便的应用
				
				addEvent();
			}
			public function addEvent(){
				net.addEventListener(NetStatusEvent.NET_STATUS,showError);
				soChat = SharedObject.getRemote( "videoConferenceChat", net.uri, true );
//				soChat.addEventListener( NetStatusEvent.NET_STATUS, netStatusHandler );
//				soChat.addEventListener( AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler );
//				soChat.addEventListener( SyncEvent.SYNC, sharedObjectSyncHandler );
				soChat.client = this;
				soChat.connect( net );
				soChat.send("getName"); //发送给服务端,服务端调用每个客户端的getName方法
			}
			public function getName():void{
				trace("helloWorld")
			}
			public function send(){
				
			}
			public function showError(e:NetStatusEvent){
		
				trace(e.info.code=="NetConnection.Connect.Success");
				
			
				
			}
		]]>
	</mx:Script>
</mx:Application>
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics