The "remote shared object" in the FMS allows flash applications on multiple clients to share the same global object. When any of the clients changes this object, the system automatically sends the object back to the FMS server, and the FMS server broadcasts the object to all clients.
More broadly speaking: If the FLASH application is browsed on two machines, the operations performed on one machine will be reflected in the synchronization of the other machine.
What can this do? Electronic classrooms (for example, teachers can demonstrate teaching on one machine, and all other machines can be refreshed simultaneously), interactive games (for example, couples in the game can decorate their houses in different places ), the chat room application that needs to save records on the server (treat the chat room record as a shared object )...
The followingCodeThe official example of the source of the FMS is to drag the position of the ball on one machine, and the ball on the other machine will also move synchronously.
VaR NC: netconnection = new netconnection (); var so: Export dobject; NC. addeventlistener (netstatusevent. net_status, netstatushandler); // sharedball is a small ball instance on the stage. addeventlistener (mouseevent. mouse_down, pickup); sharedball. addeventlistener (mouseevent. mouse_up, place); sharedball. addeventlistener (mouseevent. mouse_move, moveit); sharedball. addeventlistener (mouseevent. mouse_over, mouseoverhandler); sharedb All. addeventlistener (mouseevent. mouse_out, mouseouthandler); function mouseoverhandler (E: mouseevent) {mouse. cursor = mousecursor. hand;} function mouseouthandler (E: mouseevent) {mouse. cursor = mousecursor. arrow;} NC. connect ("rtmp: // localhost/sharedball"); // connect to fmsfunction netstatushandler (E: netstatusevent) {Switch (e.info. code) {Case "netconnection. connect. success ": trace (" Congratulations! You're connected "); so = export dobject. getremote ("ballposition", NC. uri, false); so. connect (NC); so. addeventlistener (syncevent. sync, synchandler); break; default: break;} function pickup (E: mouseevent): void paie.tar get. startdrag ();} function place (E: mouseevent): void paie.tar get. stopdrag ();} function moveit (E: mouseevent): void {If (so! = NULL) {// when moving, modify the so attribute value of the shared object. setproperty ("X", sharedball. x); so. setproperty ("Y", sharedball. y) ;}} function synchandler (E: syncevent): void {// so has an object data to save the trace (SO. data. x); trace (SO. data. Y );//Program When you enter the shared object for the first time, the shared object has no value. Therefore, you need to determine the initial value if (SO. data. X = undefined | so. data. y = undefined) {sharedball. X = 50; sharedball. y = 50;} else {sharedball. X = so. data. x; sharedball. y = so. data. Y ;}}