Skip to main content
Participant
January 10, 2008
Question

AS3 getRemote shared object not working

  • January 10, 2008
  • 1 reply
  • 610 views
Hey,

I am having trouble with my shared object. It shows up as a SO in the FMS console however the .data does not show up in debug mode. I think the problem may be in the object Encoding. The onSync event is called only once it connects but is not called again. And when I call it, it traces back undefined.

Any help please?

Cheers,
Pablo


import flash.events.MouseEvent;
import flash.events.NetStatusEvent;
import flash.net.SharedObject;
import flash.net.ObjectEncoding;

NetConnection.defaultObjectEncoding=ObjectEncoding.AMF0;

var nc:NetConnection=new NetConnection();
nc.objectEncoding = ObjectEncoding.AMF0;
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, netSecurityError);
nc.connect("rtmp://***.***.**.**/test");
var mySO:SharedObject= SharedObject.getRemote("mySO", nc.uri, false);
this.mySO.addEventListener(SyncEvent.SYNC, mySync);
this.mySO.connect(nc);

//var xPos:Number = ball_mc.x;

this.mySO.data.xPosD=Number(60);
status_txt.text="Not Connected";


function netStatus(e:NetStatusEvent):void {
var info:Object =e.info;
if (info.code=="NetConnection.Connect.Success") {
status_txt.text="Connected";
}
}

function netSecurityError(e:SecurityErrorEvent):void {
//trace("netSecurityError: "+ e);
status_txt.text="Security Error";
}
var xPos:Number;

function mySync(e:SyncEvent):void {
xPos=e.target.data.xPosD;
trace("Sync xPosD: "+e.target.data.xPosD);
}

ball_mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseD);
function mouseD(e:MouseEvent):void {
e.target.startDrag();
}

ball_mc.addEventListener(MouseEvent.MOUSE_UP, mouseU);
function mouseU(e:MouseEvent):void {
e.target.stopDrag();
this.mySO.data.xPosD=ball_mc.x;
}
    This topic has been closed for replies.

    1 reply

    PablomkAuthor
    Participant
    January 11, 2008
    I am using AS3 on FMS 2