-
1. Re: shared object with complex values
jacograaff Feb 27, 2012 5:52 PM (in response to jacograaff)the way I am doing it now:
in main.asc
-----------------------------------
Client.prototype.changeConsultantStatus = function(action, selectedUserID, client){
trace("server.changeStatus: "+action+", to: "+selectedUserID+", from: "+client.userName);
users[selectedUserID].userStatus = action;
application.broadcastMsg("updateRemoteStatus",selectedUserID, action);
}
-----------------------------------
then in my flex/AIR app
-----------------------------------
private function updateRemoteStatus(event):void{
var _selectedUserID:String = event.infoObject.selectedUserID;
var _action:String = event.infoObject.action;
for (var n:int = 0; n < consultantCollection.length; n++){
if((consultantCollection[n].userID) == _selectedUserID){
traceStr("Set status for: " + consultantCollection[n].userName+" to "+_action);
consultantCollection[n].userStatus = _action;
consultantCollection.refresh();
//found it - don't look further
break;
}
}
-----------------------------------
Ideally the default update on a sharedobject change should run - like when i add or delete a "user" from the sharedobject
but i really need to change a value of a property of an existing user inside the sharedobject
}
-----------------------------------
-
2. Re: shared object with complex values
jacograaff Feb 27, 2012 5:56 PM (in response to jacograaff)ok - i am looking at this explanation (goes beyond the basic adobe ball.x and ball.y example)
http://www.justskins.com/forums/remote-shared-object-78616.html
will implement it...
-
3. Re: shared object with complex values
jacograaff Feb 27, 2012 6:25 PM (in response to jacograaff)i tried:
------------------------------------------------------------------------
Client.prototype.changeConsultantStatus = function(action, selectedUserID, client){
trace("server.changeStatus: "+action+", to: "+selectedUserID+", from: "+client.userName);
users[selectedUserID].userStatus = action;
/* option 1 */
//tempUser = this.usersSO.get[selectedUserID]; // ------------------------- throws error - TypeError: this.usersSO has no properties
tempUser = users[selectedUserID];
tempUser.userStatus = action;
this.usersSO.setProperty(selectedUserID, tempUser); // will also throw error when reffering to usersSO inside Client.prototype.function
/* option 2 */
//client.userStatus = action;
//application.broadcastMsg("updateRemoteStatus",selectedUserID, action);
}
------------------------------------------------------------------------------------------
when refering to shared object inside a Client.prototype.function
I get
TypeError: this.usersSO has no properties
-- the second option works though
-
4. Re: shared object with complex values
jacograaff Feb 27, 2012 6:57 PM (in response to jacograaff)it seems like serverside I will have to declare/instantiate the sharedobject again and link it with the stored userList variable
this.usersSO = SharedObject.get("userList", false);
as seen at
http://echo.ryerson.ca/fcsEchoSite/arraysSharedObjects/index.html
I don t have to on
application.onDisconnect and other application level functions
but I have to on
Client.prototype.someFunction and client level related functions
I'll try a bit later .....
-
5. Re: shared object with complex values
JayCharles Feb 28, 2012 4:56 AM (in response to jacograaff)I *think* I understand what you're asking here...
If you need to update a property within an object that is the value of a sharedobject slot, you need to get the property, change the value, and then set the property again.
var obj = my_so.getProperty("someslot");
obj.someproperty = somevalue
my_so.setProperty("someslot", obj);

