import mx.events.ModuleEvent;
import mx.core.UIComponent;
import flash.events.NetStatusEvent;
public var so:SharedObject;
public var nc:NetConnection;
public function init():void
{
nc=new NetConnection();
nc.connect(”rtmp://localhost/oflaDemo”);
nc.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandle);
stage.addEventListener(MouseEvent.MOUSE_DOWN,doSomeThing);
}
public function netStatusHandle(e:NetStatusEvent):void
{
if(e.info.code==”NetConnection.Connect.Success”)
{
output.text=”Success”;
so=SharedObject.getRemote(”d5″,nc.uri,true);
so.connect(nc);
so.addEventListener(SyncEvent.SYNC,soSyncHandle);
}
}
public function soSyncHandle(e:SyncEvent):void
{
output.text+=”\n”+so.data.x;
}
public function doSomeThing(e:MouseEvent):void
{
so.setProperty(”x”,e.stageX);
}
首先,不能再象as2一样,so.onSync了,必须使用侦听器so.addEventListener(SyncEvent.SYNC,functionName)。
其次,不能再象2一样,直接so.data.vername就可以赋值,现在要用so.setProperty(”vername”,value)来赋值
本文摘自:冰山上的博客:http://xinsync.xju.edu.cn/index.php/archives/33