actionscript 3 - Shared Objects Send Method() -
there appears error in adobe documentation in regards using shared object.send()
. trying execute send method clients.
i copied client , server-side code adobe , unable invoke function. compile error in output
line 31 1119: access of possibly undefined property dosomething through reference static type flash.net:sharedobject.
any suggestions how can fix as3 novice. please can me?
var nc:netconnection = new netconnection(); nc.connect("rtmfp://localhost/submitsend"); nc.addeventlistener(netstatusevent.net_status, nethandler); function nethandler(event:netstatusevent):void{ switch(event.info.code){ case "netconnection.connect.sucess": trace("connecting..."); break; case "netconnection.connect.failed": trace("unable connect up"); break; case "netconnection.connect.rejected": trace("whoops"); break; } } var so:sharedobject = sharedobject.getremote("myso", nc.uri, true); so.connect(nc); so.dosomething = function(str) { // process str object. };
server side:
var = sharedobject.get("myso", true); so.send("dosomething", "this test");
as said in previous comment, link document you're refering welcome people helping you...
here points ought mentionned:
- you should add event listeners before call
connect()
. - you should connect shared object once received
netconnection.connect.success
event (by way, have typo in sample on name) - you should set class instance client of shared object.
i'm not sure of fix issue can try this:
var nc:netconnection = new netconnection(); private function nethandler(event:netstatusevent):void { switch(event.info.code) { case "netconnection.connect.success": { trace("connecting..."); connectsharedobject(); break; } case "netconnection.connect.failed": { trace("unable connect up"); break; } case "netconnection.connect.rejected": { trace("whoops"); break; } } } private function connectsharedobject():void { var so:sharedobject = sharedobject.getremote("myso", nc.uri, true); so.client = this; so.connect(nc); } public function dosomething(str:string):void { // process str object. } nc.addeventlistener(netstatusevent.net_status, nethandler); nc.connect("rtmfp://localhost/submitsend");
Comments
Post a Comment