macromedia flash flashcom:
I'm trying to make a lobby that initializes other FMS applications. Here's the situation: Media Server Side -onAppStart()- 1) Read an XML file from a remote server 2) Parse out application URLs (i.e. <applicationURL>rtmp://localhost/application_name/room_number</applicationURL> 3) Attempt to connect to the URL on the server side (nc.connect(applicationURL)) 4) If this returns NetConnection.Connect.Success, add to the shared object ROOMS_SO.setProperty(room_number, applicationURL) - this is happening in nc.onStatus() Client Side -ROOMS_SO.onSync()- 1) dataGrid_mc.removeAll(); 2) for(i in list) {dataGrid_mc.addItem(list[i]);} The Problem: This works fine when users connect and disconnect, but as soon as more than one user is connected, the ROOMS_SO.onSync() method is called over-and-over-and-over... which means my dataGrid_mc object is being refreshed infinitely. The only way I can stop it is to disconnect all users but one. Any thoughts? I have a users_so object updating a list (basically a "who's here" list) without any problems whatsoever using the same method (minus the XML / net connection business) Code breakdown (simplified for clarity): --= Server Side =-- (in onAppStart()) applicationURLs_so = SharedObject.get("applicationURLs_so", false); xmlObj.onLoad = function() { var nodes = this.firstChild.childNodes; var connectionURL = ""; var uniqueID = ""; for(i = 0; i < nodes.length; i++) { connectionURL = nodes[i].childNodes[0].nodeValue; uniqueID = nodes[i].childNodes[1].nodeValue; initConnection(connectionURL, uniqueID); } } initConnection = function(connectionURL, uniqueID) { var nc = new NetConnection(); nc.connect(connectionURL); nc.onStatus = function(info) { if(info.code == "NetConnection.Connect.Success") {applicationURLs_so.setProperty(uniqueID, connectionURL);} try {this.close();} catch(exception) {} } } --= Client Side =-- applicationURLs_so.onSync = function(info) { dataGrid_mc.removeAll(); for(i in this.data) {dataGrid_mc.addItem(this.data[i]);} }
Turns out this line --> for(i in this.data) {dataGrid_mc.addItem(this.data);} <-- is the culprit When adding the shared object to the dataGrid component it fires the onSync event (again) thus making the grid infinitely refresh itself. Solution: - Put the elements of the shared object into a new object - Pass the new object to the data grid.
Don't see what you're looking for? Try a search.
|