Question
sharedobject.connect() fails .. AS3/Flex
But about every 6th time the app starts, the
sharedobject.connect(nc) fails to connect. I can see it fails
because it does not sync, as well, it does not register on the
server. If have a try, catch on the connect and it shows nothing.
What should I be catching???
I'm setting it up like this: My question, what am I missing to catch an error when the SharedObject.connect() fails?
In AS2.0, the connect would return a true or false. In AS3, which I'm using, it returns null.
nc.addEventListener(NetStatusEvent.NET_STATUS, onStatus );
nc.connect(..... );
public function onStatus( event:NetStatusEvent ):void{
var info = event.info;
switch( event.info.code ) {
case "NetConnection.Connect.Success":
connectSO();
break;
....
}
public function connectSO() {
try {
this.so = SharedObject.getRemote( this.sopath + "xxx", this.nc.uri, true);
this.so.addEventListener(SyncEvent.SYNC, onSync);
this.so.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError );
this.so.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
this.so.connect( m_nc );
this.so.client = this;
} catch (err:Error)
{
.....
}
}
//put these for the client
public function asyncError( evt:Object) {
}
public function netStatus( evt:Object) {
}
public function sync( evt:Object) {
}
I'm setting it up like this: My question, what am I missing to catch an error when the SharedObject.connect() fails?
In AS2.0, the connect would return a true or false. In AS3, which I'm using, it returns null.
nc.addEventListener(NetStatusEvent.NET_STATUS, onStatus );
nc.connect(..... );
public function onStatus( event:NetStatusEvent ):void{
var info = event.info;
switch( event.info.code ) {
case "NetConnection.Connect.Success":
connectSO();
break;
....
}
public function connectSO() {
try {
this.so = SharedObject.getRemote( this.sopath + "xxx", this.nc.uri, true);
this.so.addEventListener(SyncEvent.SYNC, onSync);
this.so.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError );
this.so.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
this.so.connect( m_nc );
this.so.client = this;
} catch (err:Error)
{
.....
}
}
//put these for the client
public function asyncError( evt:Object) {
}
public function netStatus( evt:Object) {
}
public function sync( evt:Object) {
}
