Download presentation
Presentation is loading. Please wait.
1
Content: shared objects
MODULE REAL-TIME COMMUNICATION Content: shared objects SHARED REMOTE OBJECT Schematic & Code: DESCRIPTION A client connects to the Flash Comm server using the NetConnection Class then to a shared object on the server to share data with other connected clients – like variables and arrays. Whenever the data is changed it gets sent out to all the clients and an onSynch event occurs that you use to update the clients. This allows for shared moving of objects, shared text, etc. handy for multi-user games and chats. CLIENT SWF CLIENT SWF onSynch onSynch FLASH COMM CLIENT SWF sro.data.myText = “new" onSynch SAMPLE CODE // Open connection to server client_nc = new NetConnection(); client_nc.connect("rtmp://imm.sheridanc.on.ca/studentID/someName"); // Create a remote shared object. client_nc.uri is the URI of the // NetConnection the shared object will use to connect to the server. sro = SharedObject.getRemote("sharedtext", client_nc.uri, false); // true for persistent sro sro.connect(client_nc); // nothing will work if you do not connect the sro to the NetConnection // Each time something changes in the shared object, the server // sends out a synchronization message. Note that the variables are held in the data property sro.onSync = function() { myText.text = sro.data.myProperty; } // Update the shared object every time the user types in new text myText.onChanged = function() { sro.data. myProperty = myText.text; Interactive Multimedia ~ School of Applied Computing and Engineering Sciences ~ Sheridan
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.