Hi, I’m new with FMS 3 .
I’m trying to make a MovieClip follow my mouse in both client & server using a remote Shared Object. It run but it’s lagging, how I put an updateAfterEvent() for smooth moving at client & server?
Thx 4 your help
Here’s the code,
package
{
import flash.display.MovieClip;
import flash.net.NetConnection;
import flash.net.SharedObject;
import flash.events.MouseEvent;
import flash.events.NetStatusEvent;
import flash.events.SyncEvent;
public class Pointer extends MovieClip
{
private var po:Po;
private var nc:NetConnection;
private var so:SharedObject;
function Pointer()
{
//nc
nc=new NetConnection();
nc.connect("rtmp://localhost/tes_so");
nc.addEventListener(NetStatusEvent.NET_STATUS, nc_status);
}
function nc_status(ev:NetStatusEvent)
{
var st:Boolean;var setFPSBool :Boolean;
st=ev.info.code=="NetConnection.Connect.Success";
if(st)
{
so=SharedObject.getRemote("so_", nc.uri, false);
so.connect(nc);
so.addEventListener(SyncEvent.SYNC, so_sync);
init();
}
}
function so_sync(ev:SyncEvent)
{
var i:int;
for(i=0;i<ev.changeList.length;i++)
{
if(ev.changeList*.code=="change" || ev.changeList*.code=="success")
{
if(ev.changeList*.name=="posx" || ev.changeList*.name=="posy")
{
po.x=so.data.posx;
po.y=so.data.posy;
}
}
}
}
function init()
{
po=new Po();
addChild(po);
//po.x=mouseX;
//po.y=mouseY;
stage.addEventListener(MouseEvent.MOUSE_MOVE, on_mouse_move);
}
function on_mouse_move(ev:MouseEvent)
{
so.setProperty("posx", mouseX);
so.setProperty("posy", mouseY);
//po.x=mouseX;
//po.y=mouseY;
ev.updateAfterEvent();
}
}
}